Revision 38590
Added by Michele Artini over 9 years ago
modules/dnet-information-service/trunk/src/main/java/eu/dnetlib/enabling/is/hib/objects/HibDnetResourceRelationId.java | ||
---|---|---|
1 |
package eu.dnetlib.enabling.is.hib.objects; |
|
2 |
|
|
3 |
import java.io.Serializable; |
|
4 |
|
|
5 |
import javax.persistence.Column; |
|
6 |
import javax.persistence.Embeddable; |
|
7 |
import javax.persistence.JoinColumn; |
|
8 |
import javax.persistence.ManyToOne; |
|
9 |
import javax.persistence.Transient; |
|
10 |
|
|
11 |
import org.apache.commons.lang.builder.EqualsBuilder; |
|
12 |
import org.apache.commons.lang.builder.HashCodeBuilder; |
|
13 |
|
|
14 |
@Embeddable |
|
15 |
public class HibDnetResourceRelationId implements Serializable { |
|
16 |
|
|
17 |
@Transient |
|
18 |
private static final long serialVersionUID = 831375217123239845L; |
|
19 |
|
|
20 |
@ManyToOne |
|
21 |
@JoinColumn(name = "resource_1", nullable = false) |
|
22 |
private HibDnetResource firstResource; |
|
23 |
|
|
24 |
@ManyToOne |
|
25 |
@JoinColumn(name = "resource_2", nullable = false) |
|
26 |
private HibDnetResource secondResource; |
|
27 |
|
|
28 |
@Column(name = "type", nullable = false) |
|
29 |
private String type; |
|
30 |
|
|
31 |
public HibDnetResourceRelationId() {} |
|
32 |
|
|
33 |
public HibDnetResourceRelationId(final HibDnetResource firstResource, final HibDnetResource secondResource, final String type) { |
|
34 |
this.firstResource = firstResource; |
|
35 |
this.secondResource = secondResource; |
|
36 |
this.type = type; |
|
37 |
} |
|
38 |
|
|
39 |
public final HibDnetResource getFirstResource() { |
|
40 |
return firstResource; |
|
41 |
} |
|
42 |
|
|
43 |
public final void setFirstResource(final HibDnetResource firstResource) { |
|
44 |
this.firstResource = firstResource; |
|
45 |
} |
|
46 |
|
|
47 |
public final HibDnetResource getSecondResource() { |
|
48 |
return secondResource; |
|
49 |
} |
|
50 |
|
|
51 |
public final void setSecondResource(final HibDnetResource secondResource) { |
|
52 |
this.secondResource = secondResource; |
|
53 |
} |
|
54 |
|
|
55 |
public final String getType() { |
|
56 |
return type; |
|
57 |
} |
|
58 |
|
|
59 |
public final void setType(final String type) { |
|
60 |
this.type = type; |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public boolean equals(final Object obj) { |
|
65 |
if (obj == this) { |
|
66 |
return true; |
|
67 |
} else if (obj instanceof HibDnetResourceRelationId) { |
|
68 |
final HibDnetResourceRelationId rid = (HibDnetResourceRelationId) obj; |
|
69 |
return new EqualsBuilder() |
|
70 |
.append(firstResource, rid.firstResource) |
|
71 |
.append(secondResource, rid.secondResource) |
|
72 |
.append(type, rid.type) |
|
73 |
.isEquals(); |
|
74 |
} else { |
|
75 |
return false; |
|
76 |
} |
|
77 |
} |
|
78 |
|
|
79 |
@Override |
|
80 |
public int hashCode() { |
|
81 |
return new HashCodeBuilder().append(firstResource).append(secondResource).append(type).toHashCode(); |
|
82 |
} |
|
83 |
|
|
84 |
} |
modules/dnet-information-service/trunk/src/main/java/eu/dnetlib/enabling/is/hib/objects/HibServiceProtocolId.java | ||
---|---|---|
14 | 14 |
@Embeddable |
15 | 15 |
public class HibServiceProtocolId implements Serializable { |
16 | 16 |
|
17 |
/** |
|
18 |
* |
|
19 |
*/ |
|
20 | 17 |
@Transient |
21 | 18 |
private static final long serialVersionUID = 8246645893738069769L; |
22 | 19 |
|
modules/dnet-information-service/trunk/src/main/java/eu/dnetlib/enabling/is/hib/objects/HibDnetResourceRelation.java | ||
---|---|---|
1 |
package eu.dnetlib.enabling.is.hib.objects; |
|
2 |
|
|
3 |
import java.io.Serializable; |
|
4 |
|
|
5 |
import javax.persistence.EmbeddedId; |
|
6 |
import javax.persistence.Entity; |
|
7 |
import javax.persistence.Inheritance; |
|
8 |
import javax.persistence.InheritanceType; |
|
9 |
import javax.persistence.Table; |
|
10 |
import javax.persistence.Transient; |
|
11 |
|
|
12 |
@Entity(name = "resource_relations") |
|
13 |
@Table(name = "resource_relations") |
|
14 |
@Inheritance(strategy = InheritanceType.JOINED) |
|
15 |
public class HibDnetResourceRelation extends HibDnetObject implements Serializable { |
|
16 |
|
|
17 |
@Transient |
|
18 |
private static final long serialVersionUID = 6280514398623123036L; |
|
19 |
|
|
20 |
@EmbeddedId |
|
21 |
private HibDnetResourceRelationId id; |
|
22 |
|
|
23 |
public HibDnetResourceRelation(final HibDnetResourceRelationId id) { |
|
24 |
this.id = id; |
|
25 |
} |
|
26 |
|
|
27 |
public final HibDnetResourceRelationId getId() { |
|
28 |
return id; |
|
29 |
} |
|
30 |
|
|
31 |
public final void setId(final HibDnetResourceRelationId id) { |
|
32 |
this.id = id; |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
public boolean equals(final Object obj) { |
|
37 |
if (obj == this) { |
|
38 |
return true; |
|
39 |
} else if (obj != null && obj instanceof HibDnetResourceRelation) { |
|
40 |
return id.equals(((HibDnetResourceRelation) obj).id); |
|
41 |
} else { |
|
42 |
return false; |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public int hashCode() { |
|
48 |
return id.hashCode(); |
|
49 |
} |
|
50 |
} |
modules/dnet-information-service/trunk/src/main/java/eu/dnetlib/enabling/is/hib/objects/HibDnetResource.java | ||
---|---|---|
40 | 40 |
@OneToMany(mappedBy = "id.resource", cascade = CascadeType.ALL, fetch = FetchType.EAGER) |
41 | 41 |
private Set<HibDnetResourceProperty> properties = Sets.newLinkedHashSet(); |
42 | 42 |
|
43 |
@OneToMany(mappedBy = "id.firstResource", cascade = CascadeType.ALL, fetch = FetchType.EAGER) |
|
44 |
private Set<HibDnetResourceRelation> relations = Sets.newLinkedHashSet(); |
|
45 |
|
|
46 |
@OneToMany(mappedBy = "id.secondResource", cascade = CascadeType.ALL, fetch = FetchType.EAGER) |
|
47 |
private Set<HibDnetResourceRelation> inverseRelations = Sets.newLinkedHashSet(); |
|
48 |
|
|
43 | 49 |
public HibDnetResource() {} |
44 | 50 |
|
45 | 51 |
public HibDnetResource(final String id, final boolean valid) { |
... | ... | |
104 | 110 |
public int hashCode() { |
105 | 111 |
return id.hashCode(); |
106 | 112 |
} |
113 |
|
|
114 |
public final Set<HibDnetResourceRelation> getRelations() { |
|
115 |
return relations; |
|
116 |
} |
|
117 |
|
|
118 |
public final void setRelations(final Set<HibDnetResourceRelation> relations) { |
|
119 |
this.relations = relations; |
|
120 |
} |
|
121 |
|
|
122 |
public final Set<HibDnetResourceRelation> getInverseRelations() { |
|
123 |
return inverseRelations; |
|
124 |
} |
|
125 |
|
|
126 |
public final void setInverseRelations(final Set<HibDnetResourceRelation> inverseRelations) { |
|
127 |
this.inverseRelations = inverseRelations; |
|
128 |
} |
|
107 | 129 |
} |
modules/dnet-information-service/trunk/src/main/resources/eu/dnetlib/enabling/is/setup/is_base.sql | ||
---|---|---|
13 | 13 |
date timestamp NOT NULL DEFAULT now() |
14 | 14 |
); |
15 | 15 |
|
16 |
CREATE TABLE IF NOT EXISTS resource_relations ( |
|
17 |
resource_1 varchar(255) NOT NULL, |
|
18 |
resource_2 varchar(255) NOT NULL, |
|
19 |
type varchar(255) NOT NULL, |
|
20 |
PRIMARY KEY (resource_1, resource_2, type) |
|
21 |
); |
|
22 |
|
|
16 | 23 |
CREATE TABLE IF NOT EXISTS services ( |
17 | 24 |
id varchar(255) NOT NULL PRIMARY KEY REFERENCES resources(id) ON DELETE CASCADE, |
18 | 25 |
type varchar(255) NOT NULL |
modules/dnet-components/trunk/src/main/java/eu/dnetlib/rmi/objects/is/DnetResource.java | ||
---|---|---|
1 |
package eu.dnetlib.rmi.objects.is; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import com.google.common.collect.Maps; |
|
7 |
|
|
8 |
public abstract class DnetResource { |
|
9 |
|
|
10 |
private String id; |
|
11 |
private Date date; |
|
12 |
private boolean valid = true; |
|
13 |
private Map<String, DnetResource> relations = Maps.newLinkedHashMap(); |
|
14 |
|
|
15 |
public DnetResource() {} |
|
16 |
|
|
17 |
public DnetResource(final String id, final Date date, final boolean valid) { |
|
18 |
this.id = id; |
|
19 |
this.date = date; |
|
20 |
this.valid = valid; |
|
21 |
} |
|
22 |
|
|
23 |
public final String getId() { |
|
24 |
return id; |
|
25 |
} |
|
26 |
|
|
27 |
public final void setId(final String id) { |
|
28 |
this.id = id; |
|
29 |
} |
|
30 |
|
|
31 |
public final Date getDate() { |
|
32 |
return date; |
|
33 |
} |
|
34 |
|
|
35 |
public final void setDate(final Date date) { |
|
36 |
this.date = date; |
|
37 |
} |
|
38 |
|
|
39 |
public final boolean isValid() { |
|
40 |
return valid; |
|
41 |
} |
|
42 |
|
|
43 |
public final void setValid(final boolean valid) { |
|
44 |
this.valid = valid; |
|
45 |
} |
|
46 |
|
|
47 |
public final Map<String, DnetResource> getRelations() { |
|
48 |
return relations; |
|
49 |
} |
|
50 |
|
|
51 |
public final void setRelations(final Map<String, DnetResource> relations) { |
|
52 |
this.relations = relations; |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public int hashCode() { |
|
57 |
return id.hashCode(); |
|
58 |
} |
|
59 |
} |
modules/dnet-components/trunk/src/main/java/eu/dnetlib/rmi/objects/is/DnetDataStructure.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.rmi.objects.is; |
2 | 2 |
|
3 |
import java.util.Date; |
|
4 | 3 |
import java.util.Map; |
5 | 4 |
|
6 | 5 |
import javax.xml.bind.annotation.XmlRootElement; |
... | ... | |
12 | 11 |
import eu.dnetlib.rmi.soap.exceptions.InformationServiceException; |
13 | 12 |
|
14 | 13 |
@XmlRootElement |
15 |
public class DnetDataStructure { |
|
14 |
public class DnetDataStructure extends DnetResource {
|
|
16 | 15 |
|
17 |
private String id; |
|
18 | 16 |
private String code; |
19 | 17 |
private String name; |
20 | 18 |
private String description; |
21 | 19 |
private String type; |
22 |
private Date date; |
|
23 |
private boolean valid = true; |
|
24 | 20 |
private String serviceId; |
25 | 21 |
private String content; |
26 | 22 |
private Map<String, String> properties = Maps.newHashMap(); |
27 | 23 |
|
28 |
public String getId() { |
|
29 |
return id; |
|
30 |
} |
|
31 |
|
|
32 |
public void setId(final String id) { |
|
33 |
this.id = id; |
|
34 |
} |
|
35 |
|
|
36 | 24 |
public String getCode() { |
37 | 25 |
return code; |
38 | 26 |
} |
... | ... | |
65 | 53 |
this.type = type; |
66 | 54 |
} |
67 | 55 |
|
68 |
public Date getDate() { |
|
69 |
return date; |
|
70 |
} |
|
71 |
|
|
72 |
public void setDate(final Date date) { |
|
73 |
this.date = date; |
|
74 |
} |
|
75 |
|
|
76 |
public boolean isValid() { |
|
77 |
return valid; |
|
78 |
} |
|
79 |
|
|
80 |
public void setValid(final boolean valid) { |
|
81 |
this.valid = valid; |
|
82 |
} |
|
83 |
|
|
84 | 56 |
public String getServiceId() { |
85 | 57 |
return serviceId; |
86 | 58 |
} |
... | ... | |
108 | 80 |
|
109 | 81 |
@Override |
110 | 82 |
public String toString() { |
111 |
return String.format("[ id = %s, type = %s ]", id, type);
|
|
83 |
return String.format("[ id = %s, type = %s ]", getId(), type);
|
|
112 | 84 |
} |
113 | 85 |
|
114 |
@Override |
|
115 |
public int hashCode() { |
|
116 |
return id.hashCode(); |
|
117 |
} |
|
118 |
|
|
119 | 86 |
public Map<String, String> getProperties() { |
120 | 87 |
return properties; |
121 | 88 |
} |
modules/dnet-components/trunk/src/main/java/eu/dnetlib/rmi/objects/is/DnetService.java | ||
---|---|---|
10 | 10 |
import com.google.common.collect.Sets; |
11 | 11 |
|
12 | 12 |
@XmlRootElement |
13 |
public class DnetService { |
|
13 |
public class DnetService extends DnetResource {
|
|
14 | 14 |
|
15 |
private String id; |
|
16 | 15 |
private String name; |
17 |
private Date date; |
|
18 |
private boolean valid = true; |
|
19 | 16 |
private Map<String, String> protocols = Maps.newHashMap(); |
20 | 17 |
private Map<String, String> properties = Maps.newHashMap(); |
21 | 18 |
private Set<BlackboardMessageContainer> blackboard = Sets.newLinkedHashSet(); |
... | ... | |
26 | 23 |
public DnetService(final String id, final String name, final Date date, final boolean valid, final Map<String, String> protocols, |
27 | 24 |
final Map<String, String> properties, |
28 | 25 |
final Set<BlackboardMessageContainer> blackboard, final Set<Subscription> subscriptions) { |
29 |
this.id = id;
|
|
26 |
super(id, date, valid);
|
|
30 | 27 |
this.name = name; |
31 |
this.date = date; |
|
32 |
this.valid = valid; |
|
33 | 28 |
this.protocols = protocols; |
34 | 29 |
this.properties = properties; |
35 | 30 |
this.blackboard = blackboard; |
36 | 31 |
this.subscriptions = subscriptions; |
37 | 32 |
} |
38 | 33 |
|
39 |
public String getId() { |
|
40 |
return id; |
|
41 |
} |
|
42 |
|
|
43 |
public void setId(final String id) { |
|
44 |
this.id = id; |
|
45 |
} |
|
46 |
|
|
47 | 34 |
public String getName() { |
48 | 35 |
return name; |
49 | 36 |
} |
... | ... | |
52 | 39 |
this.name = name; |
53 | 40 |
} |
54 | 41 |
|
55 |
public Date getDate() { |
|
56 |
return date; |
|
57 |
} |
|
58 |
|
|
59 |
public void setDate(final Date date) { |
|
60 |
this.date = date; |
|
61 |
} |
|
62 |
|
|
63 |
public boolean isValid() { |
|
64 |
return valid; |
|
65 |
} |
|
66 |
|
|
67 |
public void setValid(final boolean valid) { |
|
68 |
this.valid = valid; |
|
69 |
} |
|
70 |
|
|
71 | 42 |
public Map<String, String> getProtocols() { |
72 | 43 |
return protocols; |
73 | 44 |
} |
... | ... | |
102 | 73 |
|
103 | 74 |
@Override |
104 | 75 |
public String toString() { |
105 |
return String.format("[ id = %s, type = %s ]", id, name);
|
|
76 |
return String.format("[ id = %s, type = %s ]", getId(), name);
|
|
106 | 77 |
} |
107 | 78 |
|
108 |
@Override |
|
109 |
public int hashCode() { |
|
110 |
return id.hashCode(); |
|
111 |
} |
|
112 | 79 |
} |
Also available in: Unified diff
Service relations