|
[HepData-svn] r1854 - trunk/hepdata-webapp/src/main/java/cedar/hepdata/formatsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgWed Apr 8 16:50:04 BST 2015
Author: whalley Date: Wed Apr 8 16:50:04 2015 New Revision: 1854 Log: modifications to include more metadata items Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MarcXMLFormatter.java Modified: trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MarcXMLFormatter.java ============================================================================== --- trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MarcXMLFormatter.java Mon Mar 30 17:18:28 2015 (r1853) +++ trunk/hepdata-webapp/src/main/java/cedar/hepdata/formats/MarcXMLFormatter.java Wed Apr 8 16:50:04 2015 (r1854) @@ -9,6 +9,8 @@ import java.util.*; import java.text.*; +import java.io.File; +import java.io.*; import org.antlr.stringtemplate.*; @@ -69,6 +71,92 @@ s.append(" <controlfield tag=\"001\">"+id+"</controlfield>\n"); s.append(" <controlfield tag=\"005\">"+ds.getPaper().getDateUpdated()+"</controlfield>\n"); + + if( ds.getPaper().getModifications().size()>0){ + int count=0; + for (Modification m : ds.getPaper().getModifications()){ + count++; + s.append(" <datafield tag=\"999\" ind1=\"\" ind2=\"\">\n"); + s.append(" <subfield code=\"9\">HEPDATA</subfield>\n") ; + if(m.getAction() != null) { + s.append(" <subfield code=\"a\">"+m.getAction()+"</subfield>\n"); + } + else{ + if(count==1) { s.append(" <subfield code=\"a\">Encoded</subfield>\n");} + else { s.append(" <subfield code=\"a\">Modified</subfield>\n"); } + } + s.append(" <subfield code=\"m\">"+m.getModifier()+"</subfield>\n"); + s.append(" <subfield code=\"d\">"+m.getComment()+"</subfield>\n"); + s.append(" </datafield>\n"); + } + } + + + + s.append(" <datafield tag=\"520\" ind1=\"\" ind2=\"\">\n"); + s.append(" <subfield code=\"9\">HEPDATA</subfield>\n") ; + s.append(" <subfield code=\"a\">") ; + for (String ct : ds.getPaper().getComments()){ + s.append(ct.replaceAll(">",">").replaceAll("<","<")); + } + s.append(" </subfield>\n"); + s.append(" </datafield>\n"); + +// here we deal with the extra resource and description/line files + String[] descs = { "description1" , "description2" , "description3" , "description4" }; + String[] links = { "link1" , "link2" , "link3" , "link4" }; + String[] ids = new String[3]; + if(p.getSpiresId() != null ) { ids[0]=p.getSpiresId().toString(); } else { ids[0]=""; } + if(p.getInspireId() != null ) { ids[1]=p.getInspireId().toString(); } else { ids[1]=""; } + if(p.getRedId() != null ) { ids[2]=p.getRedId().toString(); } else { ids[2]=""; } + + for (int i=0; i<descs.length; i++){ + for(int j=0; j<ids.length; j++){ + String descfile = "/mt/hepdata/resource/" +ids[j] + "/" + descs[i]; + String linkfile = "/mt/hepdata/resource/" +ids[j] + "/" + links[i]; + File testdesc = new File(descfile); + File testlink = new File(linkfile); + String desc=""; + String link=""; + if(testdesc.exists() && testlink.exists() ){ + try { + BufferedReader in = new BufferedReader(new FileReader(descfile)); + desc=in.readLine(); + } + catch (IOException e){} + try { + BufferedReader in = new BufferedReader(new FileReader(linkfile)); + link=in.readLine(); + } + catch (IOException e){} + s.append(" <datafield tag=\"521\" ind1=\"\" ind2=\"\">\n"); + s.append(" <subfield code=\"9\">HEPDATA</subfield>\n") ; + s.append(" <subfield code=\"d\">"+desc+"</subfield>\n"); + if(link.startsWith("/resource")){ + s.append(" <subfield code=\"l\">http://hepdata.cedar.ac.uk"+link+"</subfield>\n"); + } else { + s.append(" <subfield code=\"l\">"+link+"</subfield>\n"); + } + s.append(" </datafield>\n"); + } + } + } + + +// next the insert.html file in the resource area + + for (int j=0; j<ids.length; j++){ + String insertfile = "/mt/hepdata/resource/" +ids[j] + "/insert.html"; + File testinsert = new File(insertfile); + String insert=""; + if(testinsert.exists()){ + s.append(" <datafield tag=\"521\" ind1=\"\" ind2=\"\">\n"); + s.append(" <subfield code=\"9\">HEPDATA</subfield>\n") ; + s.append(" <subfield code=\"i\">http://hepdata.cedar.ac.uk/resource/"+ids[j]+"/insert.html</subfield>\n"); + s.append(" </datafield>\n"); + } + } + s.append(" <datafield tag=\"245\" ind1=\"\" ind2=\"\">\n"); s.append(" <subfield code=\"9\">HEPDATA</subfield>\n") ; s.append(" <subfield code=\"a\">") ; @@ -96,6 +184,7 @@ s.append(" </subfield>\n"); s.append(" </datafield>\n"); + s.append(" <datafield tag=\"652\" ind1=\"\" ind2=\"\">\n"); for (String dsreac : ds.getDsReactions()){ s.append(" <subfield code=\"r\">") ;
More information about the HepData-svn mailing list |