devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From re...@apache.org
Subject svn commit: r1693775 - in /devicemap/trunk/clients/2.0/reference: src/DeviceMapClient.java test.sh
Date Sat, 01 Aug 2015 22:22:49 GMT
Author: rezan
Date: Sat Aug  1 22:22:48 2015
New Revision: 1693775

URL: http://svn.apache.org/r1693775
Log:
fixes for patch files

Modified:
    devicemap/trunk/clients/2.0/reference/src/DeviceMapClient.java
    devicemap/trunk/clients/2.0/reference/test.sh

Modified: devicemap/trunk/clients/2.0/reference/src/DeviceMapClient.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/DeviceMapClient.java?rev=1693775&r1=1693774&r2=1693775&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/DeviceMapClient.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/DeviceMapClient.java Sat Aug  1 22:22:48 2015
@@ -61,14 +61,25 @@ public class DeviceMapClient {
 
     //PARSE PATTERN FILE JSON
     
-    if(!patternFile.getType().equals("pattern")) {
+    if(!patternFile.getType().equals("pattern") && !patternFile.getType().equals("patternPatch"))
{
       throw new Exception("Unknown pattern file type: " + patternFile.getType());
     }
     
     boolean patch = false;
 
-    if(domain == null) {
-      domain = patternFile.getDomain();
+    if((patternFile.getType().equals("pattern") && domain != null) ||
+        (patternFile.getType().equals("patternPatch") && domain == null)) {
+
+    }
+
+    if(patternFile.getType().equals("pattern")) {
+      if(domain != null) {
+        throw new Exception("Invalid pattern file type: " + patternFile.getType());
+      } else {
+        domain = patternFile.getDomain();
+      }
+    } else if(domain == null) {
+      throw new Exception("Invalid pattern file type: " + patternFile.getType());
     } else if(!domain.equals(patternFile.getDomain())) {
       throw new Exception("Domains do not match: " + domain + " != " + patternFile.getDomain());
     } else {
@@ -129,9 +140,9 @@ public class DeviceMapClient {
 
           Main.log("Found tokenSeperator: '" + tokenSeperator + "'", 2);
         }
-      }
 
-      Main.log("Found " + tokenSeperators.size() + " tokenSeperator(s)", 1);
+        Main.log("Found " + tokenSeperators.size() + " tokenSeperator(s)", 1);
+      }
 
       //NGRAM SIZE
 
@@ -149,6 +160,8 @@ public class DeviceMapClient {
 
     //PATTERN SET
 
+    int simpleHashCount = 0;
+
     if(JsonFile.get(patternFile.getJsonNode(), "patternSet").isObject()) {
       JsonNode patternSet = patternFile.getJsonNode().get("patternSet");
 
@@ -160,13 +173,15 @@ public class DeviceMapClient {
 
       if(patternSet.get("simpleHashCount") != null) {
         String simpleHashCountStr = patternSet.get("simpleHashCount").asText();
-        int simpleHashCount = Integer.parseInt(simpleHashCountStr);
+        simpleHashCount = Integer.parseInt(simpleHashCountStr);
 
         if(simpleHashCount < 1) {
           throw new Exception("Invalid value of simpleHashCount: " + simpleHashCount);
         }
 
-        patterns = new HashMap<>(simpleHashCount);
+        if(!patch) {
+          patterns = new HashMap<>(simpleHashCount);
+        }
       }
 
       //PATTERNS
@@ -201,6 +216,10 @@ public class DeviceMapClient {
         throw new Exception("No patterns found");
       }
 
+      if(simpleHashCount > 0 && (patternCount != simpleHashCount)) {
+        throw new Exception("Bad simpleHashCount value, found: " + simpleHashCount + ", expected:
" + patternCount);
+      }
+
       Main.log("Found " + patternCount + " pattern(s), total: " + patterns.size(), 1);
     }
 
@@ -215,7 +234,8 @@ public class DeviceMapClient {
 
     //PARSE ATTRIBUTE FILE JSON
     
-    if(!attributeFile.getType().equals("pattern") && !attributeFile.getType().equals("attribute"))
{
+    if(!attributeFile.getType().equals("pattern") && !attributeFile.getType().equals("attribute")
&&
+        !attributeFile.getType().equals("patternPatch") && !attributeFile.getType().equals("attributePatch"))
{
       throw new Exception("Unknown pattern file type: " + attributeFile.getType());
     }
 
@@ -223,6 +243,11 @@ public class DeviceMapClient {
       throw new Exception("Domains do not match: " + domain + " != " + attributeFile.getDomain());
     }
 
+    if((attributeFile.getType().contains("Patch") && attributes.isEmpty()) ||
+        (!attributeFile.getType().contains("Patch") && !attributes.isEmpty())) {
+      throw new Exception("Invalid attribute file type: " + attributeFile.getType());
+    }
+
     if(!attributeFile.getDomainVersion().equals(domainVersion)) {
       throw new Exception("DomainVersions do not match: " + domainVersion + " != " + attributeFile.getDomainVersion());
     }

Modified: devicemap/trunk/clients/2.0/reference/test.sh
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/test.sh?rev=1693775&r1=1693774&r2=1693775&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/test.sh (original)
+++ devicemap/trunk/clients/2.0/reference/test.sh Sat Aug  1 22:22:48 2015
@@ -36,13 +36,14 @@ do
     A=`find $DROOT -type f | grep attribute | sort | sed "s/^/-a /" | xargs echo`
     T=`find $DROOT -type f | grep test | sort | sed "s/^/-t /" | xargs echo`
 
-    CMD="./run.sh $P $A $T -v"
-    ./run.sh $P $A $T -q
+    CMD="./run.sh $P $A $T -q"
+
+    $CMD
 
     if [ "$?" != "0" ]
     then
         FAIL="$FAIL $DOMAIN"
-        echo "Failed command: $CMD"
+        echo "CMD: $CMD"
     else
         PASS="$PASS $DOMAIN"
     fi



Mime
View raw message