| author | ymh <ymh.work@gmail.com> |
| Wed, 03 Apr 2013 23:36:05 +0200 | |
| changeset 135 | f3957d594203 |
| parent 92 | 1723936b3836 |
| child 222 | 6ac00231ee34 |
| permissions | -rw-r--r-- |
| 45 | 1 |
package org.iri_research.renkan.models; |
2 |
||
|
135
f3957d594203
Replace UUID.RandomUUID by type 1 uuids
ymh <ymh.work@gmail.com>
parents:
92
diff
changeset
|
3 |
import org.iri_research.renkan.Constants; |
| 84 | 4 |
import org.springframework.beans.factory.annotation.Autowired; |
| 45 | 5 |
import org.springframework.data.mongodb.core.mapping.DBRef; |
6 |
import org.springframework.data.mongodb.core.mapping.Document; |
|
| 71 | 7 |
import org.springframework.data.mongodb.core.mapping.Field; |
8 |
||
| 92 | 9 |
import com.fasterxml.jackson.annotation.JsonIgnore; |
| 71 | 10 |
import com.fasterxml.jackson.annotation.JsonProperty; |
| 45 | 11 |
|
12 |
||
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
13 |
@Document(collection="edges") |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
14 |
public class Edge extends AbstractRenkanModel<String> { |
| 45 | 15 |
|
16 |
@DBRef |
|
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
17 |
private Node from; |
| 45 | 18 |
|
19 |
@DBRef |
|
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
20 |
private Node to; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
21 |
|
| 71 | 22 |
@Field("project_id") |
23 |
@JsonProperty("project_id") |
|
24 |
private String projectId; |
|
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
25 |
|
| 71 | 26 |
@Field("created_by") |
27 |
@JsonProperty("created_by") |
|
28 |
private String createdBy; |
|
| 84 | 29 |
|
30 |
@SuppressWarnings("unused") |
|
31 |
private Edge() { |
|
32 |
} |
|
|
46
7e132e2a48ca
add most of the model and repositories
ymh <ymh.work@gmail.com>
parents:
45
diff
changeset
|
33 |
|
| 84 | 34 |
public Edge(Edge edge, Node from, Node to, String projectId) { |
|
135
f3957d594203
Replace UUID.RandomUUID by type 1 uuids
ymh <ymh.work@gmail.com>
parents:
92
diff
changeset
|
35 |
this(Constants.UUID_GENERATOR.generate().toString(), edge.title, edge.description, edge.uri, edge.color, from, to, edge.createdBy, projectId); |
| 84 | 36 |
} |
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
37 |
|
| 84 | 38 |
public Edge(Edge edge) { |
39 |
this(edge, edge.from, edge.to, edge.projectId); |
|
40 |
} |
|
41 |
||
42 |
@Autowired(required=true) |
|
| 71 | 43 |
public Edge(String id, String title, String description, String uri, String color, Node from, Node to, String createdBy, String projectId) { |
| 60 | 44 |
super(id,title, description, uri, color); |
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
45 |
this.from = from; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
46 |
this.to = to; |
| 71 | 47 |
this.createdBy = createdBy; |
48 |
this.projectId = projectId; |
|
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
49 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
50 |
|
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
51 |
|
| 71 | 52 |
@JsonProperty("project_id") |
53 |
public String getProjectId() { |
|
54 |
return projectId; |
|
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
55 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
56 |
|
| 45 | 57 |
|
| 71 | 58 |
public String getCreatedBy() { |
59 |
return createdBy; |
|
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
60 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
61 |
|
| 92 | 62 |
@JsonIgnore |
63 |
public Node getFromNode() { |
|
64 |
return this.from; |
|
65 |
} |
|
66 |
|
|
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
67 |
public String getFrom() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
68 |
if(this.from != null) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
69 |
return this.from.id; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
70 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
71 |
else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
72 |
return null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
73 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
74 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
75 |
|
| 92 | 76 |
@JsonIgnore |
77 |
public Node getToNode() { |
|
78 |
return this.to; |
|
79 |
} |
|
80 |
|
|
|
47
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
81 |
public String getTo() { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
82 |
if(this.to != null) { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
83 |
return this.to.id; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
84 |
} |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
85 |
else { |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
86 |
return null; |
|
267d67791e05
first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents:
46
diff
changeset
|
87 |
} |
| 45 | 88 |
} |
| 84 | 89 |
|
| 45 | 90 |
} |