1 package org.simantics.interop.update.model;
3 import org.simantics.db.Resource;
4 import org.simantics.db.Statement;
5 import org.simantics.db.WriteGraph;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.interop.test.GraphChanges;
8 import org.simantics.utils.datastructures.Pair;
10 public class PropertyChange {
11 protected GraphChanges changes;
12 protected Pair<Statement, Statement> pair;
13 protected boolean applied = false;
14 protected boolean selected = false;
15 protected boolean visible = true;
18 public PropertyChange(GraphChanges changes, Statement first, Statement second) {
19 this.pair = new Pair<Statement, Statement>(first, second);
20 this.changes = changes;
23 public PropertyChange(GraphChanges changes, Pair<Statement, Statement> change) {
25 this.changes = changes;
28 public Statement getFirst() {
32 public Statement getSecond() {
36 public GraphChanges getChanges() {
41 public int hashCode() {
42 return pair.hashCode();
46 public boolean equals(Object obj) {
49 if (obj.getClass() != this.getClass())
51 PropertyChange c = (PropertyChange)obj;
52 return pair.equals(c.pair);
55 public void apply(WriteGraph graph) throws DatabaseException {
58 if (pair.second == null) {
59 graph.deny(pair.first);
62 Resource s = changes.getComparable().getLeft(pair.second.getSubject());
63 //Resource s = pair.first.getSubject();
64 Resource pred = pair.second.getPredicate();
65 if (graph.hasValue(pair.second.getObject())) {
66 Object value = graph.getValue(pair.second.getObject());
67 graph.claimLiteral(s, pred, value);
75 public boolean select(boolean select) {
78 this.selected = select;
83 public boolean selected() {
87 public boolean applied() {
91 public boolean isVisible() {
95 public void setVisible(boolean visible) {
96 this.visible = visible;