|
[HepData-svn] r1933 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/formatsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri Mar 18 15:01:01 GMT 2016
Author: watt Date: Fri Mar 18 15:01:01 2016 New Revision: 1933 Log: YAML (and input) export: suppress duplicate paper comments and concatenate multiple data comments Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java Wed Mar 9 11:22:32 2016 (r1932) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/InputFormatter.java Fri Mar 18 15:01:01 2016 (r1933) @@ -49,9 +49,20 @@ if(p.getTitle()!=null) { s.append("*title: "+p.getTitle()+"\n"); } - for (String comment : p.getComments()){ - //comment=comment.replaceAll("\\\\n","\\\\\\\\n"); - s.append("*comment: "+comment+"\n"); + if (p.getComments().size() > 0) { + s.append("*comment: "); + List <String> comarray = new ArrayList(); + StringBuffer b = new StringBuffer(); + for (String comment : p.getComments()) { + int printcom = 1; + for (int ii = 0; ii < comarray.size(); ii++) { + if (comment.trim().equals(comarray.get(ii))) { printcom = 0; } + } + comarray.add(comment.trim()); + if (printcom == 1) { + s.append(comment+".\n"); + } + } } } for (Dataset d : ds) { @@ -72,11 +83,15 @@ stemp = stemp.substring(0, stemp.length() - 1); s.append(stemp + "\n"); } + boolean first=true; for (String comment : ds.getComments()){ - if(!comment.startsWith("Location")){ - //comment=comment.replaceAll("\\\\n","\\\\\\\\n"); - s.append("*dscomment: "+comment+"\n"); - } + if (!comment.startsWith("Location")) { + if (first) { + s.append("*dscomment: "); + first = false; + } + s.append(comment + ".\n"); + } } for (String re : ds.getDsReactions()){ s.append("*reackey: "+re+"\n"); Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java Wed Mar 9 11:22:32 2016 (r1932) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/YamlFormatter.java Fri Mar 18 15:01:01 2016 (r1933) @@ -82,17 +82,19 @@ } } - if(p.getComments().size()>0){ + if (p.getComments().size() > 0) { s.append("comment: | # preserve newlines\n"); - boolean first=true; - for (String comment : p.getComments()){ - if(first){ - s.append(s4+comment.replaceAll("\n","\n ")+"."); - first=false; - } else { - s.append(s4+comment.replaceAll("\n","\n ")+"."); - } - s.append("\n"); + List <String> comarray = new ArrayList(); + StringBuffer b = new StringBuffer(); + for (String comment : p.getComments()) { + int printcom = 1; + for (int ii = 0; ii < comarray.size(); ii++) { + if (comment.trim().equals(comarray.get(ii))) { printcom = 0; } + } + comarray.add(comment.trim()); + if (printcom == 1) { + s.append(s4 + comment.replaceAll("\n","\n ") + ".\n"); + } } } @@ -193,19 +195,17 @@ } } - boolean first=true; - for (String ct : ds.getComments()){ - if(!ct.startsWith("Location:")) { - s.append("description: |\n"); - if(first){ - s.append(s4+ct.replaceFirst("VERBATIM","").replaceAll("\n","\n ")+"."); - first=false; - } else { - s.append(s4+ct.replaceFirst("VERBATIM","").replaceAll("\n","\n ")+"."); - } - s.append("\n"); - } - } + boolean first=true; + for (String ct : ds.getComments()){ + if (!ct.startsWith("Location:")) { + if (first) { + s.append("description: |\n"); + first = false; + } + s.append(s4+ct.replaceFirst("VERBATIM","").replaceAll("\n","\n ")+".\n"); + } + } + s.append("keywords:\n"); if(ds.getDsReactions().size() > 0) { s.append(sp+"{name: reactions, values: [");
More information about the HepData-svn mailing list |