Skip to content

Commit

Permalink
create copy on project
Browse files Browse the repository at this point in the history
  • Loading branch information
firestar committed Nov 20, 2023
1 parent 781118d commit 0715789
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = 'com.nucleodb'
version = '1.10.9'
version = '1.10.10'

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,63 +213,63 @@ public void createTopics() {
public Set<Connection> getByFrom(DataEntry de) {
Set<Connection> tmp = connections.get(de.getKey());
if (tmp != null) {
return tmp.stream().map(c -> c.clone()).collect(Collectors.toSet());
return tmp.stream().map(c->c.copy(Connection.class)).collect(Collectors.toSet());
}
return new TreeSetExt<>();
}

public Set<Connection> getByFromAndLabel(DataEntry from, String label) {
Set<Connection> tmp = connections.get(from.getKey() + label);
if (tmp != null) {
return tmp.stream().map(c -> c.clone()).collect(Collectors.toSet());
return tmp.stream().map(c->c.copy(Connection.class)).collect(Collectors.toSet());
}
return new TreeSetExt<>();
}

public Set<Connection> getByFromAndLabelAndTo(DataEntry from, String label, DataEntry to) {
Set<Connection> tmp = connections.get(from.getKey() + to.getKey() + label);
if (tmp != null) {
return tmp.stream().collect(Collectors.toSet());
return tmp.stream().map(c->c.copy(Connection.class)).collect(Collectors.toSet());
}
return new TreeSetExt<>();
}

public Set<Connection> getByLabel(String label) {
Set<Connection> tmp = connections.get(label);
if (tmp != null) {
return tmp.stream().collect(Collectors.toSet());
return tmp.stream().map(c->c.copy(Connection.class)).collect(Collectors.toSet());
}
return new TreeSetExt<>();
}

public Set<Connection> getByFromAndTo(DataEntry from, DataEntry to) {
Set<Connection> tmp = connections.get(from.getKey() + to.getKey());
if (tmp != null) {
return tmp.stream().collect(Collectors.toSet());
return tmp.stream().map(c->c.copy(Connection.class)).collect(Collectors.toSet());
}
return new TreeSetExt<>();
}

public Set<Connection> getReverseByLabelAndTo(String label, DataEntry to) {
Set<Connection> tmp = connectionsReverse.get(to.getKey() + label);
if (tmp != null) {
return tmp.stream().collect(Collectors.toSet());
return tmp.stream().map(c->c.copy(Connection.class)).collect(Collectors.toSet());
}
return new TreeSetExt<>();
}

public Set<Connection> getReverseByFromAndLabelAndTo(DataEntry de, String label, DataEntry toDe) {
Set<Connection> tmp = connectionsReverse.get(de.getKey() + toDe.getKey() + label);
if (tmp != null) {
return tmp.stream().collect(Collectors.toSet());
return tmp.stream().map(c->c.copy(Connection.class)).collect(Collectors.toSet());
}
return new TreeSetExt<>();
}

public Set<Connection> getReverseByFromAndTo(DataEntry from, DataEntry to) {
Set<Connection> tmp = connectionsReverse.get(from.getKey() + to.getKey());
if (tmp != null) {
return tmp.stream().collect(Collectors.toSet());
return tmp.stream().map(c->c.copy(Connection.class)).collect(Collectors.toSet());
}
return new TreeSetExt<>();
}
Expand Down Expand Up @@ -474,9 +474,8 @@ public void startup() {

private boolean deleteInternal(Connection connection, String changeUUID) throws IOException {
if (allConnections.contains(connection)) {
Connection conn = connection.copy(Connection.class);
conn.versionIncrease();
ConnectionDelete deleteEntry = new ConnectionDelete(changeUUID, conn);
connection.versionIncrease();
ConnectionDelete deleteEntry = new ConnectionDelete(changeUUID, connection);
producer.push(deleteEntry.getUuid(), deleteEntry.getVersion(), deleteEntry, null);
return true;
}
Expand All @@ -489,17 +488,16 @@ private boolean saveInternal(Connection connection, String changeUUID) {
producer.push(createEntry.getConnection().getUuid(), createEntry.getConnection().getVersion(), createEntry, null);
return true;
} else {
Connection conn = connection.copy(Connection.class);
conn.versionIncrease();
connection.versionIncrease();
List<JsonOperations> changes = null;
Connection oldConnection = connectionByUUID.get(conn.getUuid());
JsonPatch patch = JsonDiff.asJsonPatch(Serializer.getObjectMapper().getOm().valueToTree(oldConnection), Serializer.getObjectMapper().getOm().valueToTree(conn));
Connection oldConnection = connectionByUUID.get(connection.getUuid());
JsonPatch patch = JsonDiff.asJsonPatch(Serializer.getObjectMapper().getOm().valueToTree(oldConnection), Serializer.getObjectMapper().getOm().valueToTree(connection));
try {
String json = Serializer.getObjectMapper().getOm().writeValueAsString(patch);
changes = Serializer.getObjectMapper().getOm().readValue(json, List.class);
//Serializer.log(json);
if (changes != null && changes.size() > 0) {
ConnectionUpdate updateEntry = new ConnectionUpdate(conn.getVersion(), json, changeUUID, conn.getUuid());
ConnectionUpdate updateEntry = new ConnectionUpdate(connection.getVersion(), json, changeUUID, connection.getUuid());
producer.push(updateEntry.getUuid(), updateEntry.getVersion(), updateEntry, null);
return true;
}
Expand Down

0 comments on commit 0715789

Please sign in to comment.