1 | package org.biohackathon.SPARQLBuilder.OWL;
|
---|
2 |
|
---|
3 | import org.json.JSONException;
|
---|
4 | import org.json.JSONObject;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * 繧ッ繝ゥ繧ケ縺ク縲√≠繧九>縺ッ繧ッ繝ゥ繧ケ縺九i縺ョ1繧ケ繝�ャ繝励Μ繝ウ繧ッ繧定ィ倩ソー縺吶k
|
---|
8 | * @author Norio KOBAYASHI
|
---|
9 | * @since 28.01.2014
|
---|
10 | * @version 29.01.2014
|
---|
11 | */
|
---|
12 | public class ClassLink {
|
---|
13 |
|
---|
14 | private String propertyURI = null;
|
---|
15 | private String linkedClassURI = null;
|
---|
16 | private String linkedLiteralDatatypeURI = null;
|
---|
17 | private Direction direction = null;
|
---|
18 | private int numOfLinks = 0;
|
---|
19 | private int numOfLinkedInstances = 0;
|
---|
20 | private int numOfOriginInstances = 0;
|
---|
21 | private int numOfOriginClassInstances = 0;
|
---|
22 | private int numOfLinkedClassInstances = 0;
|
---|
23 | private boolean domainClassLimitedQ = false;
|
---|
24 | private boolean rangeClassLimitedQ = false;
|
---|
25 |
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * 繝励Ο繝代ユ繧」URI縲√Μ繝ウ繧ッ蜈茨シ亥��峨け繝ゥ繧ケ縲√Μ繝ウ繧ッ縺ョ蜷代″繧剃ク弱∴繧区ァ区�蟄� |
---|
29 | *
|
---|
30 | * @param propertyURI縲繝励Ο繝代ユ繧」縺ョURI
|
---|
31 | * @param linkedClassURI縲繝ェ繝ウ繧ッ縺ョ荳サ隱槭√√≠繧九>縺ッ繝ェ繝ウ繧ッ縺ョ逶ョ逧�ェ槭→縺ェ縺」縺ヲ縺�k繧ッ繝ゥ繧ケ縺ョURI
|
---|
32 | * @param direction 繝励Ο繝代ユ繧」縺ョ蜷代″縲〕inkedClassURI縺ョ繧ッ繝ゥ繧ケ縺後Μ繝ウ繧ッ蜈医↓縺ェ縺」縺ヲ縺�k縺ィ縺阪�Direction.forward,繝ェ繝ウ繧ッ蜈�↓縺ェ縺」縺ヲ縺�k縺ィ縺阪�Direction.reverse, 縺昴l繧我ク。譁ケ縺ョ譎ゅ�Direction.both繧呈欠螳壹☆繧�
|
---|
33 | * @param numOfLinks 蠖楢ゥイ繝励Ο繝代ユ繧」縺ァ荳。遶ッ繧ッ繝ゥ繧ケ縺ョ繧、繝ウ繧ケ繧ソ繝ウ繧ケ蜷悟」ォ繧偵▽縺ェ縺�〒縺�k繝ェ繝ウ繧ッ謨ー�医ヨ繝ェ繝励Ν謨ー�� |
---|
34 | * @throws Exception
|
---|
35 | * @since 28.01.2014
|
---|
36 | */
|
---|
37 | public ClassLink(String propertyURI, String linkedClassURI, String linkedLiteralDatatypeURI, Direction direction,
|
---|
38 | int numLinks, int numOfOriginInstances, int numOfLinkedInstances,
|
---|
39 | int numOfOriginClassInstances, int numofLinkedClassInstances,
|
---|
40 | boolean domainClassLimitedQ, boolean rangeClassLimitedQ){
|
---|
41 | this.propertyURI = propertyURI;
|
---|
42 | this.linkedClassURI = linkedClassURI;
|
---|
43 | this.linkedLiteralDatatypeURI = linkedLiteralDatatypeURI;
|
---|
44 | this.direction = direction;
|
---|
45 | this.numOfLinks = numLinks;
|
---|
46 | this.numOfLinkedInstances = numOfLinkedInstances;
|
---|
47 | this.numOfOriginInstances = numOfOriginInstances;
|
---|
48 | this.numOfOriginClassInstances = numOfOriginClassInstances;
|
---|
49 | this.numOfLinkedClassInstances = numofLinkedClassInstances;
|
---|
50 | this.domainClassLimitedQ = domainClassLimitedQ;
|
---|
51 | this.rangeClassLimitedQ = rangeClassLimitedQ;
|
---|
52 | }
|
---|
53 |
|
---|
54 |
|
---|
55 | public JSONObject toJSON() throws JSONException{
|
---|
56 | JSONObject obj = new JSONObject();
|
---|
57 | if( propertyURI != null ) {
|
---|
58 | obj.put("propertyURI", propertyURI);
|
---|
59 | }
|
---|
60 | if( linkedClassURI != null ){
|
---|
61 | obj.put("linkedClassURI", linkedClassURI);
|
---|
62 | }
|
---|
63 | if( linkedLiteralDatatypeURI != null ){
|
---|
64 | obj.put("linkedLiteralDatatypeURI", linkedLiteralDatatypeURI);
|
---|
65 | }
|
---|
66 | if( direction != null ){
|
---|
67 | obj.put("direction", direction);
|
---|
68 | }
|
---|
69 | //obj.put("numOfLinks", numOfLinks);
|
---|
70 | //obj.put("numOfLinkedInstances", numOfLinkedInstances);
|
---|
71 | //obj.put("numOfOriginInstances", numOfOriginInstances);
|
---|
72 | //obj.put("numOfOriginClassInstances", numOfOriginClassInstances);
|
---|
73 | //obj.put("numOfLinkedClassInstances", numOfLinkedClassInstances);
|
---|
74 | return obj;
|
---|
75 | }
|
---|
76 | // add direction and other variations
|
---|
77 | public String toJSONString2() {
|
---|
78 | String json_str ="{";
|
---|
79 |
|
---|
80 | if( propertyURI != null ) {
|
---|
81 | json_str+="\"propertyURI\":"+"\""+propertyURI+"\",";
|
---|
82 | }
|
---|
83 | else{
|
---|
84 | json_str+="\"propertyURI\":"+"\"propertyURI\",";
|
---|
85 | }
|
---|
86 | if( linkedClassURI != null ){
|
---|
87 | json_str+="\"linkedClassURI\":"+"\""+linkedClassURI+"\",";
|
---|
88 | }
|
---|
89 | else{
|
---|
90 | json_str+="\"linkedClassURI\":"+"\"linkedClassURI\",";
|
---|
91 | }
|
---|
92 | if( linkedLiteralDatatypeURI != null ){
|
---|
93 | json_str+="\"linkedLiteralDatatypeURI\":"+"\""+linkedLiteralDatatypeURI+"\",";
|
---|
94 | }
|
---|
95 | else{
|
---|
96 | json_str+="\"linkedLiteralDatatypeURI\":"+"\"linkedLiteralDatatypeURI\",";
|
---|
97 | }
|
---|
98 | if( direction != null ){
|
---|
99 | json_str+="\"direction\":"+"\""+direction.toString()+"\"";
|
---|
100 | }
|
---|
101 | else{
|
---|
102 | json_str+="\"direction\":"+"\"direction\"";
|
---|
103 | }
|
---|
104 |
|
---|
105 | // json_str+="\"numOfLinks\":"+"\""+numOfLinks+"\",";
|
---|
106 | // json_str+="\"numOfLinkedInstances\":"+"\""+numOfLinkedInstances+"\",";
|
---|
107 | // json_str+="\"numOfOriginInstances\":"+"\""+numOfOriginInstances+"\",";
|
---|
108 | // json_str+="\"numOfOriginClassInstances\":"+"\""+numOfOriginClassInstances+"\",";
|
---|
109 | // json_str+="\"numOfLinkedClassInstances\":"+"\""+numOfLinkedClassInstances+"\"";
|
---|
110 |
|
---|
111 | json_str+="}";
|
---|
112 |
|
---|
113 | return json_str;
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | public int getNumOfLinks() {
|
---|
118 | return numOfLinks;
|
---|
119 | }
|
---|
120 |
|
---|
121 |
|
---|
122 |
|
---|
123 |
|
---|
124 | public void setNumOfLinks(int numOfLinks) {
|
---|
125 | this.numOfLinks = numOfLinks;
|
---|
126 | }
|
---|
127 |
|
---|
128 |
|
---|
129 |
|
---|
130 |
|
---|
131 | /**
|
---|
132 | * 譁�ュ怜�陦ィ險倥r蜿門セ励☆繧� |
---|
133 | *
|
---|
134 | * @since 28.01.2014
|
---|
135 | */
|
---|
136 | public String toString(){
|
---|
137 | StringBuffer sb = new StringBuffer();
|
---|
138 | sb.append(propertyURI);
|
---|
139 | if( direction == Direction.forward ){
|
---|
140 | sb.append(" --> ");
|
---|
141 | }else{
|
---|
142 | if( direction == Direction.reverse ){
|
---|
143 | sb.append(" <-- ");
|
---|
144 | }else{
|
---|
145 | sb.append(" <-> ");
|
---|
146 | }
|
---|
147 | }
|
---|
148 | sb.append(linkedClassURI);
|
---|
149 | sb.append(" [");
|
---|
150 | sb.append(numOfOriginClassInstances);
|
---|
151 | sb.append("/");
|
---|
152 | sb.append(numOfOriginInstances);
|
---|
153 | sb.append("]縲---");
|
---|
154 |
|
---|
155 |
|
---|
156 | sb.append(" [");
|
---|
157 | sb.append(numOfLinks);
|
---|
158 | sb.append("] --->");
|
---|
159 |
|
---|
160 | sb.append(" [");
|
---|
161 | sb.append(numOfLinkedClassInstances);
|
---|
162 | sb.append("/");
|
---|
163 | sb.append(numOfLinkedInstances);
|
---|
164 | sb.append("]");
|
---|
165 | return sb.toString();
|
---|
166 | }
|
---|
167 |
|
---|
168 | public String getPropertyURI() {
|
---|
169 | return propertyURI;
|
---|
170 | }
|
---|
171 | public void setPropertyURI(String propertyURI) {
|
---|
172 | this.propertyURI = propertyURI;
|
---|
173 | }
|
---|
174 | public String getLinkedClassURI() {
|
---|
175 | return linkedClassURI;
|
---|
176 | }
|
---|
177 | public void setLinkedClassURI(String linkedClassURI) {
|
---|
178 | this.linkedClassURI = linkedClassURI;
|
---|
179 | }
|
---|
180 | public Direction getDirection() {
|
---|
181 | return direction;
|
---|
182 | }
|
---|
183 | public void setDirection(Direction direction) {
|
---|
184 | this.direction = direction;
|
---|
185 | }
|
---|
186 |
|
---|
187 | public final int getNumOfLinkedInstances() {
|
---|
188 | return numOfLinkedInstances;
|
---|
189 | }
|
---|
190 |
|
---|
191 | public final void setNumOfLinkedInstances(int numOfLinkedInstances) {
|
---|
192 | this.numOfLinkedInstances = numOfLinkedInstances;
|
---|
193 | }
|
---|
194 |
|
---|
195 |
|
---|
196 |
|
---|
197 |
|
---|
198 | public final boolean isDomainClassLimitedQ() {
|
---|
199 | return domainClassLimitedQ;
|
---|
200 | }
|
---|
201 |
|
---|
202 |
|
---|
203 | public final boolean isRangeClassLimitedQ() {
|
---|
204 | return rangeClassLimitedQ;
|
---|
205 | }
|
---|
206 |
|
---|
207 |
|
---|
208 | public final int getNumOfOriginInstances() {
|
---|
209 | return numOfOriginInstances;
|
---|
210 | }
|
---|
211 |
|
---|
212 |
|
---|
213 | public final void setNumOfOriginInstances(int numOfOriginInstances) {
|
---|
214 | this.numOfOriginInstances = numOfOriginInstances;
|
---|
215 | }
|
---|
216 |
|
---|
217 |
|
---|
218 | public final int getNumOfOriginClassInstances() {
|
---|
219 | return numOfOriginClassInstances;
|
---|
220 | }
|
---|
221 |
|
---|
222 |
|
---|
223 | public final void setNumOfOriginClassInstances(int numOfOriginClassInstances) {
|
---|
224 | this.numOfOriginClassInstances = numOfOriginClassInstances;
|
---|
225 | }
|
---|
226 |
|
---|
227 |
|
---|
228 | public final int getNumOfLinkedClassInstances() {
|
---|
229 | return numOfLinkedClassInstances;
|
---|
230 | }
|
---|
231 |
|
---|
232 |
|
---|
233 | public final void setNumOfLinkedClassInstances(int numOfLinkedClassInstances) {
|
---|
234 | this.numOfLinkedClassInstances = numOfLinkedClassInstances;
|
---|
235 | }
|
---|
236 |
|
---|
237 |
|
---|
238 | public final String getLinkedLiteralDatatypeURI() {
|
---|
239 | return linkedLiteralDatatypeURI;
|
---|
240 | }
|
---|
241 |
|
---|
242 |
|
---|
243 | public final void setLinkedLiteralDatatypeURI(String linkedLiteralDatatypeURI) {
|
---|
244 | this.linkedLiteralDatatypeURI = linkedLiteralDatatypeURI;
|
---|
245 | }
|
---|
246 |
|
---|
247 |
|
---|
248 | public final void setDomainClassLimitedQ(boolean domainClassLimitedQ) {
|
---|
249 | this.domainClassLimitedQ = domainClassLimitedQ;
|
---|
250 | }
|
---|
251 |
|
---|
252 |
|
---|
253 | public final void setRangeClassLimitedQ(boolean rangeClassLimitedQ) {
|
---|
254 | this.rangeClassLimitedQ = rangeClassLimitedQ;
|
---|
255 | }
|
---|
256 |
|
---|
257 |
|
---|
258 |
|
---|
259 | // private String[] propertyDomainClassURIs = null;
|
---|
260 | // private String[] propertyRangeClassURIs = null;
|
---|
261 |
|
---|
262 |
|
---|
263 |
|
---|
264 | }
|
---|