Commits

Sam Adams committed 022a1f8

Fixed lots of checkstyle violations

Comments (0)

Files changed (6)

chemistry-common/src/main/java/net/chempound/chemistry/Cml2RdfConverter.java

 
     protected Property getHasProperty(final Model model, final QName dictRef) {
         String localPart = dictRef.getLocalPart();
-        localPart = "has"+Character.toUpperCase(localPart.charAt(0)) + localPart.substring(1);
+        localPart = "has" + Character.toUpperCase(localPart.charAt(0)) + localPart.substring(1);
         final String uri = getPropertyUri(dictRef.getNamespaceURI(), localPart);
         return model.createProperty(uri);
     }
     protected QName getDictRefUri(final String dictRef, final CMLElement context) {
         final int i = dictRef.indexOf(':');
         final String prefix = dictRef.substring(0, i);
-        final String localName = dictRef.substring(i+1);
+        final String localName = dictRef.substring(i + 1);
         final String uri = context.getNamespaceURI(prefix);
         if (uri == null) {
             LOG.warn("No dictRef URI: " + dictRef);

chemistry-common/src/main/java/net/chempound/chemistry/CmlRdfUtils.java

             final DateTime dt = scalar.getDate();
             return model.createTypedLiteral(dt.toDate());
         }
-        throw new IllegalArgumentException("Unsupported data type: "+dataType);
+        throw new IllegalArgumentException("Unsupported data type: " + dataType);
     }
 
     public static RDFNode createUnitsNode(final CMLScalar scalar, final Model model) {
     public static String getDictRefUri(final String dictRef, final CMLElement context) {
         final int i = dictRef.indexOf(':');
         final String prefix = dictRef.substring(0, i);
-        final String localName = dictRef.substring(i+1);
+        final String localName = dictRef.substring(i + 1);
         final String uri = context.getNamespaceURI(prefix);
         if (uri == null) {
             // TODO

chemistry-common/src/main/java/net/chempound/chemistry/cml/CmlUtils.java

                 return new QName(convention);
             }
             final String prefix = convention.substring(0, i);
-            final String localPart = convention.substring(i+1);
+            final String localPart = convention.substring(i + 1);
             final String namespaceUri = module.getNamespaceURIForPrefix(prefix);
             return new QName(namespaceUri, localPart, prefix);
         }

chemistry-common/src/main/java/net/chempound/chemistry/inchi/InchiTool.java

  * <p>
  * Tool for the creation of InChIs from CML molecules.
  * </p>
- * 
+ *
  * @author Nick Day
  * @author Sam Adams
  * @version 0.2
  */
 public class InchiTool {
 
-	private static final Logger LOG = Logger.getLogger(InchiTool.class);
-	
-	/**
-	 * <p>
-	 * Generate the InChI for the objects molecule using the InChI program
-	 * options provided as a parameter.
-	 * </p>
-	 *
-	 * @param options - the InChI program options to be used for generation.
-	 *
-	 * @return the InChI string for the objects molecule. Returns null if there
-	 * was a problem during generation.
-	 */
-	public static String generateInchi(final CMLMolecule molecule, final String options) {
+    private static final Logger LOG = Logger.getLogger(InchiTool.class);
+
+    /**
+     * <p>
+     * Generate the InChI for the objects molecule using the InChI program
+     * options provided as a parameter.
+     * </p>
+     *
+     * @param options - the InChI program options to be used for generation.
+     * @return the InChI string for the objects molecule. Returns null if there
+     *         was a problem during generation.
+     */
+    public static String generateInchi(final CMLMolecule molecule, final String options) {
         if (molecule == null) {
             throw new IllegalArgumentException("Null argument: molecule");
         }
                 return output.getInchi();
             }
             if (output.getReturnStatus() == INCHI_RET.WARNING) {
-                LOG.warn("Warning generating InChI: "+output.getMessage());
+                LOG.warn("Warning generating InChI: " + output.getMessage());
                 return output.getInchi();
             }
-            throw new RuntimeException("Error generating InChI: "+output.getMessage());
+            throw new RuntimeException("Error generating InChI: " + output.getMessage());
         } catch (JniInchiException e) {
             throw new RuntimeException(e);
         }
-	}
+    }
 
     public static String generateInchiKey(final String inchi) {
         if (inchi == null) {
         }
     }
 
-	/**
-	 * <p>
-	 * Creates a complete <code>JniInchiInput</code> object representing
-	 * the structure in the object CML molecule.  NOTE that this method
-	 * assumes that the provided CMLMolecule has 3D coordinates for all
-	 * atoms, and allows the InChI tool to calculate the stereochemical
-	 * flags instead of having to input them explicitly.
-	 * </p>
-	 *
-	 * @param options - the InChI program options to be used in creating
-	 * the InChI input.
-	 *
-	 * @return a complete <code>JniInchiInput</code> object representing
-	 * the structure in the object CML molecule.
-	 *
-	 * @throws net.sf.jniinchi.JniInchiException if there is an error is generating the
-	 * <code>JniInchiInput</code>.
-	 */
-	private static JniInchiInput getInchiInput(final CMLMolecule molecule, final String options) throws JniInchiException {
-		final JniInchiInput input = new JniInchiInput(options);
-		final Map<String, JniInchiAtom> jniAtomList = new HashMap<String, JniInchiAtom>(molecule.getAtomCount());
-		for (final CMLAtom atom : molecule.getAtoms()) {
+    /**
+     * <p>
+     * Creates a complete <code>JniInchiInput</code> object representing
+     * the structure in the object CML molecule.  NOTE that this method
+     * assumes that the provided CMLMolecule has 3D coordinates for all
+     * atoms, and allows the InChI tool to calculate the stereochemical
+     * flags instead of having to input them explicitly.
+     * </p>
+     *
+     * @param options - the InChI program options to be used in creating
+     *                the InChI input.
+     * @return a complete <code>JniInchiInput</code> object representing
+     *         the structure in the object CML molecule.
+     * @throws net.sf.jniinchi.JniInchiException
+     *          if there is an error is generating the
+     *          <code>JniInchiInput</code>.
+     */
+    private static JniInchiInput getInchiInput(final CMLMolecule molecule, final String options) throws JniInchiException {
+        final JniInchiInput input = new JniInchiInput(options);
+        final Map<String, JniInchiAtom> jniAtomList = new HashMap<String, JniInchiAtom>(molecule.getAtomCount());
+        for (final CMLAtom atom : molecule.getAtoms()) {
             final JniInchiAtom inchiAtom = new JniInchiAtom(atom.getX3(), atom.getY3(), atom.getZ3(), atom.getElementType());
             inchiAtom.setImplicitH(0);
             final JniInchiAtom a1 = input.addAtom(inchiAtom);
-			jniAtomList.put(atom.getId(), a1);
-		}
-		for (final CMLBond bond : molecule.getBonds()) {
-			final String[] atomRefs = bond.getAtomRefs2();
-			final JniInchiAtom a0 = jniAtomList.get(atomRefs[0]);
-			final JniInchiAtom a1 = jniAtomList.get(atomRefs[1]);
-			input.addBond(new JniInchiBond(a0, a1, getBondType(bond)));
-		}
-		return input;
-	}
+            jniAtomList.put(atom.getId(), a1);
+        }
+        for (final CMLBond bond : molecule.getBonds()) {
+            final String[] atomRefs = bond.getAtomRefs2();
+            final JniInchiAtom a0 = jniAtomList.get(atomRefs[0]);
+            final JniInchiAtom a1 = jniAtomList.get(atomRefs[1]);
+            input.addBond(new JniInchiBond(a0, a1, getBondType(bond)));
+        }
+        return input;
+    }
 
-	/**
-	 * <p>
-	 * Gets the bond type for the provided CML bond.
-	 * </p>
-	 *
-	 * @param bond whose type you want to returned.
-	 *
-	 * @return bond type of the provided bond.
-	 */
-	private static INCHI_BOND_TYPE getBondType(final CMLBond bond) {
-		final String order = bond.getOrder();
-		if ("1".equals(order) || "S".equals(order)) {
-			return INCHI_BOND_TYPE.SINGLE;
-		} else if ("2".equals(order) || "D".equals(order)) {
-			return INCHI_BOND_TYPE.DOUBLE;
-		} else if ("3".equals(order) || "T".equals(order)) {
-			return INCHI_BOND_TYPE.TRIPLE;
-		} else {
-			return INCHI_BOND_TYPE.ALTERN;
-		}
-	}
+    /**
+     * <p>
+     * Gets the bond type for the provided CML bond.
+     * </p>
+     *
+     * @param bond whose type you want to returned.
+     * @return bond type of the provided bond.
+     */
+    private static INCHI_BOND_TYPE getBondType(final CMLBond bond) {
+        final String order = bond.getOrder();
+        if ("1".equals(order) || "S".equals(order)) {
+            return INCHI_BOND_TYPE.SINGLE;
+        } else if ("2".equals(order) || "D".equals(order)) {
+            return INCHI_BOND_TYPE.DOUBLE;
+        } else if ("3".equals(order) || "T".equals(order)) {
+            return INCHI_BOND_TYPE.TRIPLE;
+        } else {
+            return INCHI_BOND_TYPE.ALTERN;
+        }
+    }
 
 
     public static void attachIdentifiers(final Node root) {

chemistry-importer/src/main/java/net/chempound/chemistry/CmlImporter.java

 package net.chempound.chemistry;
 
-import net.chempound.ContentImporter;
+import net.chempound.AbstractContentImporter;
 import net.chempound.chemistry.cml.ChemicalMime;
 import net.chempound.content.DepositRequest;
 import net.chempound.storage.InMemoryResource;
 /**
  * @author Sam Adams
  */
-public abstract class CmlImporter extends ContentImporter {
+public abstract class CmlImporter extends AbstractContentImporter {
 
     private final ImageGenerator imageGenerator;
     private final InChIGenerator inchiGenerator;
                 final File thumbnailFile = File.createTempFile("image_tn", "png");
                 try {
                     imageGenerator.createImages(resource, ext, imageFile, thumbnailFile);
-                    imageResource = createImageResource(imageFile, id+".png");
-                    thumbnailResource = createImageResource(thumbnailFile, id+"_tn.png");
+                    imageResource = createImageResource(imageFile, id + ".png");
+                    thumbnailResource = createImageResource(thumbnailFile, id + "_tn.png");
                 } finally {
                     FileUtils.deleteQuietly(thumbnailFile);
                 }
                 final File thumbnailFile = File.createTempFile("image_tn", "png");
                 try {
                     imageGenerator.createImages(molecule, imageFile, thumbnailFile);
-                    imageResource = createImageResource(imageFile, id+".png");
-                    thumbnailResource = createImageResource(thumbnailFile, id+"_tn.png");
+                    imageResource = createImageResource(imageFile, id + ".png");
+                    thumbnailResource = createImageResource(thumbnailFile, id + "_tn.png");
                 } finally {
                     FileUtils.deleteQuietly(thumbnailFile);
                 }

chemistry-search-structure/src/main/java/net/chempound/webapp/search/chemistry/MoleculeIndexer.java

         try {
             appendToIndex(smiles, item.getUri());
         } catch (Exception e) {
-            LOG.warn("Error indexing molecule ["+item.getURI()+"]", e);
+            LOG.warn("Error indexing molecule [" + item.getURI() + "]", e);
         }
     }