Sam Adams avatar Sam Adams committed 66e62aa

Try to get title from cif

Comments (0)

Files changed (1)

src/main/java/uk/ac/cam/ch/wwmm/chempound/deposit/DepositCif.java

 package uk.ac.cam.ch.wwmm.chempound.deposit;
 
+import com.hp.hpl.jena.rdf.model.*;
+import com.hp.hpl.jena.rdf.model.Statement;
 import com.hp.hpl.jena.xmloutput.RDFXMLWriterI;
 import com.hp.hpl.jena.xmloutput.impl.Abbreviated;
 import nu.xom.ParsingException;
 import uk.ac.cam.ch.wwmm.chempound.content.DefaultContentLoadRequest;
 import uk.ac.cam.ch.wwmm.chempound.crystal.importer.CrystalStructureImporter;
 import uk.ac.cam.ch.wwmm.chempound.crystal.importer.utils.CifIO;
+import uk.ac.cam.ch.wwmm.chempound.rdf.DCTerms;
 import uk.ac.cam.ch.wwmm.chempound.storage.AggregatedResource;
 
+import javax.annotation.Resource;
 import java.io.*;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
         Deposit deposit = new Deposit();
 
         EntryPart entryPart = new EntryPart();
-        entryPart.getEntry().setTitle("Crystal Structure");
+        String title = "Crystal Structure";
 
         if (!request.getMetadataModel().isEmpty()) {
             attachMetaData(request, entryPart);
+            Statement s = request.getMetadataModel().getResource("").getRequiredProperty(DCTerms.title);
+            if (s != null) {
+                title = s.getString();
+            }
         }
+        entryPart.getEntry().setTitle(title);
         deposit.setEntryPart(entryPart);
 
         byte[] zip = createZipFile(request);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.