server/src/main/java/org/iri_research/renkan/models/Edge.java
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--
Replace UUID.RandomUUID by type 1 uuids
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
package org.iri_research.renkan.models;
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
     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
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
     4
import org.springframework.beans.factory.annotation.Autowired;
45
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
import org.springframework.data.mongodb.core.mapping.DBRef;
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
import org.springframework.data.mongodb.core.mapping.Document;
71
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
     7
import org.springframework.data.mongodb.core.mapping.Field;
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
     8
92
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
     9
import com.fasterxml.jackson.annotation.JsonIgnore;
71
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    10
import com.fasterxml.jackson.annotation.JsonProperty;
45
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
	@DBRef
47
267d67791e05 first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents: 46
diff changeset
    17
	private Node from;
45
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
	
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
    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
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    22
	@Field("project_id")
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    23
	@JsonProperty("project_id")
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    24
	private String projectId;
47
267d67791e05 first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents: 46
diff changeset
    25
	
71
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    26
	@Field("created_by")
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    27
	@JsonProperty("created_by")
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    28
	private String createdBy;
84
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    29
		
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    30
	@SuppressWarnings("unused")
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    31
	private Edge() {		
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    32
	}
46
7e132e2a48ca add most of the model and repositories
ymh <ymh.work@gmail.com>
parents: 45
diff changeset
    33
	
84
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    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
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    36
	}	
47
267d67791e05 first stabilization of editing a renkan.
ymh <ymh.work@gmail.com>
parents: 46
diff changeset
    37
84
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    38
	public Edge(Edge edge) {
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    39
		this(edge, edge.from, edge.to, edge.projectId);
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    40
	}	
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    41
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    42
	@Autowired(required=true)
71
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    43
	public Edge(String id, String title, String description, String uri, String color, Node from, Node to, String createdBy, String projectId) {
60
6a3084c7eb98 add color
ymh <ymh.work@gmail.com>
parents: 47
diff changeset
    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
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    47
		this.createdBy = createdBy;
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    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
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    52
	@JsonProperty("project_id")
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    53
	public String getProjectId() {
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    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
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
71
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    58
	public String getCreatedBy() {
9af0874ce43f First version of space level.
ymh <ymh.work@gmail.com>
parents: 60
diff changeset
    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
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
    62
	@JsonIgnore
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
    63
	public Node getFromNode() {
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
    64
		return this.from;
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
    65
	}
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
    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
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
    76
	@JsonIgnore
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
    77
	public Node getToNode() {
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
    78
		return this.to;
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
    79
	}
1723936b3836 - Add recursive delete for project
ymh <ymh.work@gmail.com>
parents: 84
diff changeset
    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
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
	}
84
b4b83e9b808d Add copy for projects
ymh <ymh.work@gmail.com>
parents: 71
diff changeset
    89
	
45
37c9a17c3284 - add Spring
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
}