From: <azu...@us...> - 2007-07-27 02:21:27
|
Revision: 779 http://obo.svn.sourceforge.net/obo/?rev=779&view=rev Author: azurebrd Date: 2007-07-26 19:21:27 -0700 (Thu, 26 Jul 2007) Log Message: ----------- WormReferenceGroupAdapter now constructs the Reference by taking the digits from the WBPaperID, followed by underscore, followed by the first 15 characters (or all if there are less than 15 characters) of the Title, followed by underscore, followed by the digits from the WBPersonID, followed by underscore, followed by the first 15 characters (or all if there are less than 15 characters) of the Name, followed by underscore, followed by first 15 from NBP (as above) followed by underscore, followed by first 15 from OtherRemark (as above) Modified Paths: -------------- phenote/trunk/src/java/phenote/dataadapter/worm/WormReferenceGroupAdapter.java Modified: phenote/trunk/src/java/phenote/dataadapter/worm/WormReferenceGroupAdapter.java =================================================================== --- phenote/trunk/src/java/phenote/dataadapter/worm/WormReferenceGroupAdapter.java 2007-07-26 23:45:07 UTC (rev 778) +++ phenote/trunk/src/java/phenote/dataadapter/worm/WormReferenceGroupAdapter.java 2007-07-27 02:21:27 UTC (rev 779) @@ -1,5 +1,7 @@ package phenote.dataadapter.worm; +import java.util.regex.*; + import org.apache.log4j.Logger; import phenote.datamodel.CharacterI; @@ -17,16 +19,38 @@ protected String makeNameFromChar(CharacterI c) { StringBuilder sb = new StringBuilder(); try { - if (c.hasValue("Pub")) - sb.append(c.getValueString("Pub")); - if (c.hasValue("Person")) - sb.append("/").append(c.getValueString("Person")); + if (c.hasValue("Pub")) { + String pubID = c.getTerm("Pub").getID(); // get the Papers's ID + String match = find("([0-9]+)", pubID); // Find a set of digits + sb.append(match); // append it to the stringbuilder + String title = c.getValueString("Pub"); // get the Paper's value (the title) + match = find("^(.{15})", title); // Find the first 15 characters + if (match != null) { sb.append("_").append(match); } // if there's a match append it + else { sb.append("_").append(title); } } // otherwise append the full title + else { sb.append("_"); } // if there's no publication append a single underscore + if (c.hasValue("Person")) { + String personID = c.getTerm("Person").getID(); + String match = find("([0-9]+)", personID); // Find a set of digits + sb.append("_").append(match); // eventually this will be a list - if (c.hasValue("NBP")) - sb.append(", ").append(c.getValueString("NBP")); + String name = c.getValueString("Person"); + match = find("^(.{15})", name); // Find the first 15 characters + if (match != null) { sb.append("_").append(match); } + else { sb.append("_").append(name); } } + else { sb.append("_").append("_"); } + if (c.hasValue("NBP")) { // this will also be a list - if (c.hasValue("OtherRemark")) - sb.append(" { ").append(c.getValueString("OtherRemark")).append(" }"); + String nbp = c.getValueString("NBP"); + String match = find("^(.{15})", nbp); // Find the first 15 characters + if (match != null) { sb.append("_").append(match); } + else { sb.append("_").append(nbp); } } + else { sb.append("_"); } + if (c.hasValue("OtherRemark")) { + String othRem = c.getValueString("OtherRemark"); + String match = find("^(.{15})", othRem); // Find the first 15 characters + if (match != null) { sb.append("_").append(match); } + else { sb.append("_").append(othRem); } } + else { sb.append("_"); } } catch (CharFieldException e) { log().error(e.getMessage()); @@ -40,4 +64,13 @@ return log; } + public static String find(String patternStr, CharSequence input) { + Pattern pattern = Pattern.compile(patternStr); + Matcher matcher = pattern.matcher(input); +// System.out.println("Pattern "+pattern+" end"); + if (matcher.find()) { return matcher.group(1); } + return null; + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |