Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
gumreal authored and gumreal committed Mar 4, 2022
1 parent f42b0e9 commit 77b52dd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ apply plugin: 'signing'

group = 'io.dgraph'
archivesBaseName = 'dgraph4j'
version = '21.03.2.p12.20220221b'
version = '21.03.2.p13.20220304a'
sourceCompatibility = 1.8
targetCompatibility = 1.8

Expand Down
34 changes: 32 additions & 2 deletions src/main/java/io/dgraph/wrapper/model/VertexBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import io.dgraph.DgraphProto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** Dgraph Custom Data Type */
public abstract class VertexBase implements Serializable {
Expand Down Expand Up @@ -61,6 +62,28 @@ public VertexBase mergeJson(String jsonStr) {
return vertex;
}

public VertexBase merge(VertexBase other) {
mergeUid(other);
mergeChildren(other);
return this;
}

/** @param other */
protected void mergeUid(VertexBase other) {
if (null == other) {
return;
}
if (isStubUid() && !other.isStubUid()) {
setUid(other.getUid());
}
}

/**
* @param other
* @return
*/
protected abstract VertexBase mergeChildren(VertexBase other);

/**
* get all property names except typeName and uid
*
Expand All @@ -75,6 +98,13 @@ public VertexBase mergeJson(String jsonStr) {
*/
public abstract Map<String, Object> primaryPairs();

/**
* primary values to a string
*
* @return
*/
public abstract String getBizKey();

public void setStubUid() {
setStubUid(1);
}
Expand Down

0 comments on commit 77b52dd

Please sign in to comment.