Skip to content

Commit

Permalink
Crawler adds more DOIs
Browse files Browse the repository at this point in the history
  • Loading branch information
BobHanson committed Nov 21, 2024
1 parent 29e66a1 commit f362b59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
28 changes: 14 additions & 14 deletions src/main/java/com/integratedgraphics/extractor/DOICrawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class DOICrawler extends FindingAidCreator {
public interface DOICustomizer {

boolean customizeText(String key, String val);
String customizeGet(String key);
String customizeKey(String key);
boolean ignoreURL(String url);

}
Expand Down Expand Up @@ -361,14 +361,13 @@ protected void processEndElement(String localName) {
Map<String, String> attrs;
switch (localName) {
case "description":
if (s.length() > 0 && !hackText("description", s)) {
if (s.length() > 0 && !customizeText("description", s)) {
crawler.addAttr(IFDConst.IFD_PROPERTY_DESCRIPTION, s);
}
break;
case "title":
System.out.println(localName + "=" + s);
if (s.length() > 0) {
if (!hackText("title", s)) {
if (!customizeText("title", s)) {
crawler.addAttr(IFDConst.IFD_PROPERTY_LABEL, s);
}
}
Expand Down Expand Up @@ -411,7 +410,7 @@ private void addSubjects(Map<String, String> attrs, String s) {
}
break;
default:
key = hackGet(key);
key = customizeKey(key);
break;
}
if (key.startsWith(FAIRSPEC_DATAOBJECT_FLAG)) {
Expand All @@ -423,12 +422,12 @@ private void addSubjects(Map<String, String> attrs, String s) {
}
}

private String hackGet(String key) {
return (customizer == null ? key : customizer.customizeGet(key));
private String customizeKey(String key) {
return (customizer == null ? key : customizer.customizeKey(key));
}

private boolean hackText(String key, String val) {
return (customizer == null || customizer.customizeText(key, val));
private boolean customizeText(String key, String val) {
return (customizer != null && customizer.customizeText(key, val));
}

}
Expand Down Expand Up @@ -918,6 +917,8 @@ protected void processRecords(String dataObjectType, List<DoiRecord> doiList) th
break;
case DOI_DATA:
o = thisDataObject = faHelper.createDataObject("" + ++ids, rec.dataObjectType);
o.setDOI(rec.ifdRef.getDOI());
o.setURL(rec.ifdRef.getURL());
thisDataObjectType = rec.dataObjectType;
break;
case DOI_REP:
Expand Down Expand Up @@ -1056,11 +1057,10 @@ public void addPropertyOrRepresentation(String key, Object val,
}

public static void main(String[] args) {
if (args.length == 0) {
args = new String[] { TEST_PID, DEFAULT_OUTDIR, "-dodownload" };
// args = new String[] { "10.14469/hpc/14443" , DEFAULT_OUTDIR, "-dodownload -bycompound" };
}
new DOICrawler(args).crawl();
if (args.length == 0)
ICLDOICrawler.main(args);
else
new DOICrawler(args).crawl();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public boolean ignoreURL(String url) {
* return mapped key or key
*/
@Override
public String customizeGet(String key) {
public String customizeKey(String key) {
String mappedKey = hackMap.get(key);
return (mappedKey == null ? key : mappedKey);
}
Expand Down

0 comments on commit f362b59

Please sign in to comment.