jenkins-bot has submitted this change and it was merged.

Change subject: update fixes
......................................................................


update fixes

Change-Id: Ie1b3d9664daa76bc2dca0d81fe9f64ec0923a7a3
---
M src/main/groovy/org/wikidata/gremlin/ConsoleInit.groovy
M src/main/groovy/org/wikidata/gremlin/DomainSpecificLanguage.groovy
M src/main/groovy/org/wikidata/gremlin/Loader.groovy
3 files changed, 40 insertions(+), 24 deletions(-)

Approvals:
  Manybubbles: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/main/groovy/org/wikidata/gremlin/ConsoleInit.groovy 
b/src/main/groovy/org/wikidata/gremlin/ConsoleInit.groovy
index 3a5a3c5..b1729a2 100644
--- a/src/main/groovy/org/wikidata/gremlin/ConsoleInit.groovy
+++ b/src/main/groovy/org/wikidata/gremlin/ConsoleInit.groovy
@@ -24,9 +24,9 @@
        protected ConsoleInit setup()
        {
                log.info "Starting console setup..."
+               super.setup()
                graph()
                schema()
-               super.setup()
                this
        }
 
diff --git a/src/main/groovy/org/wikidata/gremlin/DomainSpecificLanguage.groovy 
b/src/main/groovy/org/wikidata/gremlin/DomainSpecificLanguage.groovy
index 869b7a4..1979e04 100644
--- a/src/main/groovy/org/wikidata/gremlin/DomainSpecificLanguage.groovy
+++ b/src/main/groovy/org/wikidata/gremlin/DomainSpecificLanguage.groovy
@@ -1,9 +1,6 @@
 package org.wikidata.gremlin
 
-import com.tinkerpop.gremlin.structure.Graph
-import com.tinkerpop.gremlin.structure.Vertex
-import com.tinkerpop.gremlin.structure.Edge
-import com.tinkerpop.gremlin.structure.Direction
+import com.tinkerpop.gremlin.structure.*
 
 import org.apache.commons.lang.RandomStringUtils
 import groovy.util.logging.Slf4j
@@ -11,14 +8,28 @@
 // Apache 2 Licensed
 @Slf4j
 class DomainSpecificLanguage {
-  void setup() {
-    log.info "Setting up domain specific language"
+       
+       public static class DSLElement {
+               public static final get(final Element element, final String 
key) {
+                       final Property property = element.property(key)
+                       if (property.isPresent())
+                               return property.value();
+                       else
+                               return null
+               }
 
-    // Some syntax sugar for setting properties
-    Vertex.metaClass {
-      getProperty = { delegate.property(it).value(); }
-      setProperty = { name, value -> delegate.singleProperty(name, value); }
-    }
+               public static final set(final Element element, final String 
key, final Object value) {
+                       element.singleProperty(key, value)
+               }
+   }
+       
+  void setup() {
+       // Some syntax sugar for setting properties
+       // Conflicts with "sugar" plugin
+       Vertex.metaClass.mixin(DSLElement.class);
+       Edge.metaClass.mixin(DSLElement.class);
+       
+    log.info "Setting up domain specific language"
 
     // TODO the loader_ name seems silly
     Graph.metaClass.loader_ = null
diff --git a/src/main/groovy/org/wikidata/gremlin/Loader.groovy 
b/src/main/groovy/org/wikidata/gremlin/Loader.groovy
index 04a7a44..2551d30 100644
--- a/src/main/groovy/org/wikidata/gremlin/Loader.groovy
+++ b/src/main/groovy/org/wikidata/gremlin/Loader.groovy
@@ -369,19 +369,20 @@
                        return
                }
                for(cl in v.outE('claim')) {
-                       if(!(cl.contentHash in claimsById)) {
+                       def clHash = cl.value('contentHash')
+                       if(!(clHash in claimsById)) {
                                // This one is not there anymore, remove it
-                               def prop = cl.property('property').value()
+                               def prop = cl.value('property')
                                def targetId = null
-                               log.debug "Dropping old claim ${cl.wikibaseId}"
-                               if(isLinkType(cl.property('datatype').value())) 
{
+                               log.info "Dropping old claim ${cl.wikibaseId} 
on $prop"
+                               if(isLinkType(cl.value('datatype'))) {
                                        // Try to find target id for this link
-                                       def e = v.outE(prop).has('contentHash', 
cl.contentHash).next()
-                                       targetId = 
e.property(getValueName(prop)).value()
+                                       def e = v.outE(prop).has('contentHash', 
clHash).next()
+                                       targetId = e.value(getValueName(prop))
                                }
                                // Drop related claims
-                               v.outE('claim').has('contentHash', 
cl.contentHash).remove()
-                               v.outE(prop).has('contentHash', 
cl.contentHash).remove()
+                               v.outE('claim').has('contentHash', 
clHash).remove()
+                               v.outE(prop).has('contentHash', clHash).remove()
                                // update also the links
                                if(targetId && targetId[0] == 'Q'
                                        && !v.out(prop).has('wikibaseId', 
targetId).hasNext()) {
@@ -389,15 +390,19 @@
                                        // if this link targeted v(target) and 
there are no links to it anymore
                                        // drop it from links
                                        for(vp in v.properties(lname)) {
-                                               if(vp.value() == 
target.wikibaseId) {
+                                               if(vp.value() == targetId) {
                                                        vp.remove();
                                                        break;
                                                }
                                        }
-                                       v.singleProperty(getLinkName(prop)+"_", 
v[lname].join(' '))
+                                       if(v[lname]) {
+                                               
v.singleProperty(getLinkName(prop)+"_", v[lname].join(' '))
+                                       } else {
+                                               
v.property(getLinkName(prop)+"_").remove()
+                                       }
                                }
                        } else {
-                               claimsById[cl.contentHash].exists = true
+                               claimsById[clHash].exists = true
                        }
                }
        }
@@ -730,7 +735,7 @@
          def rank = s.addProperty(mgmt, 'rank', Boolean.class)
          def hash = s.addProperty(mgmt, "contentHash", String.class)
          def etype = s.addProperty(mgmt, 'edgeType', String.class)
-         def datatype = addProperty(mgmt, 'datatype', String.class)
+         def datatype = s.addProperty(mgmt, 'datatype', String.class)
          def label = s.addEdgeLabel(mgmt, name, rank, wikibaseId, hash, etype, 
datatype)
          
 

-- 
To view, visit https://gerrit.wikimedia.org/r/183410
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie1b3d9664daa76bc2dca0d81fe9f64ec0923a7a3
Gerrit-PatchSet: 4
Gerrit-Project: wikidata/gremlin
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to