more rar friendly appdata reference name and uniqueness check,
authorjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 28 Aug 2007 15:14:31 +0000 (15:14 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 28 Aug 2007 15:14:31 +0000 (15:14 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@446 be28352e-c001-0410-b1a7-c7978e42abec

src/uk/ac/vamsas/objects/utils/AppDataReference.java

index d982e1f..b1cf4f2 100644 (file)
@@ -146,15 +146,14 @@ public class AppDataReference {
    * @param entry base application reference to make unique 
    */
   public static String uniqueAppDataReference(VamsasDocument dest,String base) {
-    String urn = new String(base);    
-    
+    String urn = base.replace('/','.').replace('\\','.').replace(':', '_');
+    int v = 1;
     for (int i=0, j=dest.getApplicationDataCount(); i<j; i++) {
       ApplicationData o = dest.getApplicationData()[i];
       // ensure new urn is really unique
-      int v = 1;
-      // TODO: while (o.getUrn().equals(urn)) {
-        urn = base+"/"+v++;      
-      //} 
+      while (o.getDataReference()!=null && o.getDataReference().equals(urn)) {
+        urn = base+"."+v++;      
+      } 
     }
     return urn;
   }