Revize 9b0966a7
Přidáno uživatelem Tomáš Šimandl před více než 6 roky(ů)
sources/src/main/java/cz/zcu/kiv/offscreen/api/AttributeDataType.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 |
|
|
3 |
public enum AttributeDataType { |
|
4 |
NUMBER { |
|
5 |
@Override |
|
6 |
public String toString() { |
|
7 |
return "number"; |
|
8 |
} |
|
9 |
}, |
|
10 |
DATE { |
|
11 |
@Override |
|
12 |
public String toString() { |
|
13 |
return "date"; |
|
14 |
} |
|
15 |
}, |
|
16 |
ENUM { |
|
17 |
@Override |
|
18 |
public String toString() { |
|
19 |
return "enum"; |
|
20 |
} |
|
21 |
}, |
|
22 |
STRING { |
|
23 |
@Override |
|
24 |
public String toString() { |
|
25 |
return "string"; |
|
26 |
} |
|
27 |
} |
|
28 |
} |
sources/src/main/java/cz/zcu/kiv/offscreen/api/AttributeType.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 |
|
|
3 |
/** |
|
4 |
* Class represents one attribute type which is used in input JSON file and in output JSON file (file between frontend |
|
5 |
* and backend). |
|
6 |
*/ |
|
7 |
public class AttributeType { |
|
8 |
/** name of attribute */ |
|
9 |
public String name; |
|
10 |
/** data type of attribute */ |
|
11 |
public AttributeDataType dataType; |
|
12 |
/** additional info */ |
|
13 |
public String text; |
|
14 |
|
|
15 |
public AttributeType(String name, AttributeDataType dataType, String text) { |
|
16 |
this.name = name; |
|
17 |
this.dataType = dataType; |
|
18 |
this.text = text; |
|
19 |
} |
|
20 |
|
|
21 |
public String getName() { |
|
22 |
return name; |
|
23 |
} |
|
24 |
|
|
25 |
public AttributeDataType getDataType() { |
|
26 |
return dataType; |
|
27 |
} |
|
28 |
|
|
29 |
public String getText() { |
|
30 |
return text; |
|
31 |
} |
|
32 |
} |
sources/src/main/java/cz/zcu/kiv/offscreen/api/EdgeArchetype.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 |
|
|
3 |
public class EdgeArchetype { |
|
4 |
public String name; |
|
5 |
public String text; |
|
6 |
|
|
7 |
EdgeArchetype(String name, String text) { |
|
8 |
this.name = name; |
|
9 |
this.text = text; |
|
10 |
} |
|
11 |
|
|
12 |
public String getName() { |
|
13 |
return name; |
|
14 |
} |
|
15 |
|
|
16 |
public String getText() { |
|
17 |
return text; |
|
18 |
} |
|
19 |
} |
sources/src/main/java/cz/zcu/kiv/offscreen/api/Graph.java | ||
---|---|---|
1 | 1 |
package cz.zcu.kiv.offscreen.api; |
2 | 2 |
|
3 |
import cz.zcu.kiv.offscreen.graph.*; |
|
4 |
|
|
5 | 3 |
import java.util.List; |
6 | 4 |
import java.util.Map; |
7 | 5 |
import java.util.Set; |
sources/src/main/java/cz/zcu/kiv/offscreen/api/VertexArchetype.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.api; |
|
2 |
|
|
3 |
public class VertexArchetype { |
|
4 |
public String name; |
|
5 |
public String text; |
|
6 |
public String icon; |
|
7 |
|
|
8 |
VertexArchetype(String name, String text, String icon) { |
|
9 |
this.name = name; |
|
10 |
this.text = text; |
|
11 |
this.icon = icon; |
|
12 |
} |
|
13 |
|
|
14 |
VertexArchetype(String name, String text) { |
|
15 |
this(name, text, ""); |
|
16 |
} |
|
17 |
|
|
18 |
public String getName() { |
|
19 |
return name; |
|
20 |
} |
|
21 |
|
|
22 |
public String getText() { |
|
23 |
return text; |
|
24 |
} |
|
25 |
|
|
26 |
public String getIcon() { |
|
27 |
return icon; |
|
28 |
} |
|
29 |
} |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/AttributeType.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.graph; |
|
2 |
|
|
3 |
/** |
|
4 |
* Class represents one attribute type which is used in input JSON file and in output JSON file (file between frontend |
|
5 |
* and backend). |
|
6 |
*/ |
|
7 |
public class AttributeType { |
|
8 |
/** name of attribute */ |
|
9 |
public String name; |
|
10 |
/** data type of attribute */ |
|
11 |
public GraphManager.AttributeDataType dataType; |
|
12 |
/** additional info */ |
|
13 |
public String text; |
|
14 |
|
|
15 |
public AttributeType(String name, GraphManager.AttributeDataType dataType, String text) { |
|
16 |
this.name = name; |
|
17 |
this.dataType = dataType; |
|
18 |
this.text = text; |
|
19 |
} |
|
20 |
|
|
21 |
public String getName() { |
|
22 |
return name; |
|
23 |
} |
|
24 |
|
|
25 |
public GraphManager.AttributeDataType getDataType() { |
|
26 |
return dataType; |
|
27 |
} |
|
28 |
|
|
29 |
public String getText() { |
|
30 |
return text; |
|
31 |
} |
|
32 |
} |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/EdgeArchetype.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.graph; |
|
2 |
|
|
3 |
public class EdgeArchetype { |
|
4 |
public String name; |
|
5 |
public String text; |
|
6 |
|
|
7 |
EdgeArchetype(String name, String text) { |
|
8 |
this.name = name; |
|
9 |
this.text = text; |
|
10 |
} |
|
11 |
|
|
12 |
public String getName() { |
|
13 |
return name; |
|
14 |
} |
|
15 |
|
|
16 |
public String getText() { |
|
17 |
return text; |
|
18 |
} |
|
19 |
} |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/Graph.java | ||
---|---|---|
1 | 1 |
package cz.zcu.kiv.offscreen.graph; |
2 | 2 |
|
3 |
import cz.zcu.kiv.offscreen.api.Edge; |
|
4 |
import cz.zcu.kiv.offscreen.api.Vertex; |
|
3 |
import cz.zcu.kiv.offscreen.api.*; |
|
5 | 4 |
import org.apache.log4j.Logger; |
6 | 5 |
|
7 | 6 |
import java.util.*; |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/GraphManager.java | ||
---|---|---|
1 | 1 |
package cz.zcu.kiv.offscreen.graph; |
2 | 2 |
|
3 |
import cz.zcu.kiv.offscreen.api.Edge; |
|
4 |
import cz.zcu.kiv.offscreen.api.Group; |
|
5 |
import cz.zcu.kiv.offscreen.api.SubedgeInfo; |
|
6 |
import cz.zcu.kiv.offscreen.api.Vertex; |
|
3 |
import cz.zcu.kiv.offscreen.api.*; |
|
7 | 4 |
import cz.zcu.kiv.offscreen.graph.filter.*; |
8 | 5 |
import cz.zcu.kiv.offscreen.graph.loader.JSONConfigLoader; |
9 | 6 |
|
... | ... | |
11 | 8 |
|
12 | 9 |
public class GraphManager { |
13 | 10 |
|
14 |
public enum AttributeDataType { |
|
15 |
NUMBER { |
|
16 |
@Override |
|
17 |
public String toString() { |
|
18 |
return "number"; |
|
19 |
} |
|
20 |
}, |
|
21 |
DATE { |
|
22 |
@Override |
|
23 |
public String toString() { |
|
24 |
return "date"; |
|
25 |
} |
|
26 |
}, |
|
27 |
ENUM { |
|
28 |
@Override |
|
29 |
public String toString() { |
|
30 |
return "enum"; |
|
31 |
} |
|
32 |
}, |
|
33 |
STRING { |
|
34 |
@Override |
|
35 |
public String toString() { |
|
36 |
return "string"; |
|
37 |
} |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
41 | 11 |
public List<VertexArchetype> vertexArchetypes = new ArrayList<>(); |
42 | 12 |
public List<EdgeArchetype> edgeArchetypes = new ArrayList<>(); |
43 | 13 |
public List<AttributeType> attributeTypes = new ArrayList<>(); |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/VertexArchetype.java | ||
---|---|---|
1 |
package cz.zcu.kiv.offscreen.graph; |
|
2 |
|
|
3 |
public class VertexArchetype { |
|
4 |
public String name; |
|
5 |
public String text; |
|
6 |
public String icon; |
|
7 |
|
|
8 |
VertexArchetype(String name, String text, String icon) { |
|
9 |
this.name = name; |
|
10 |
this.text = text; |
|
11 |
this.icon = icon; |
|
12 |
} |
|
13 |
|
|
14 |
VertexArchetype(String name, String text) { |
|
15 |
this(name, text, ""); |
|
16 |
} |
|
17 |
|
|
18 |
public String getName() { |
|
19 |
return name; |
|
20 |
} |
|
21 |
|
|
22 |
public String getText() { |
|
23 |
return text; |
|
24 |
} |
|
25 |
|
|
26 |
public String getIcon() { |
|
27 |
return icon; |
|
28 |
} |
|
29 |
} |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/loader/GraphJSONDataLoader.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import com.google.common.base.Strings; |
4 | 4 |
import cz.zcu.kiv.offscreen.graph.Attribute; |
5 |
import cz.zcu.kiv.offscreen.api.AttributeDataType; |
|
5 | 6 |
import cz.zcu.kiv.offscreen.graph.EdgeArchetypeInfo; |
6 | 7 |
import cz.zcu.kiv.offscreen.graph.GraphManager; |
7 | 8 |
import net.sf.json.JSONArray; |
... | ... | |
91 | 92 |
for (int i = 0; i < attributeTypes.size(); i++) { |
92 | 93 |
JSONObject attributeType = attributeTypes.getJSONObject(i); |
93 | 94 |
String dataTypeString = attributeType.getString("dataType"); |
94 |
GraphManager.AttributeDataType dataType;
|
|
95 |
AttributeDataType dataType; |
|
95 | 96 |
switch (dataTypeString) { |
96 |
case "number": dataType = GraphManager.AttributeDataType.NUMBER; break;
|
|
97 |
case "date": dataType = GraphManager.AttributeDataType.DATE; break;
|
|
98 |
case "enum": dataType = GraphManager.AttributeDataType.ENUM; break;
|
|
99 |
default: dataType = GraphManager.AttributeDataType.STRING; break;
|
|
97 |
case "number": dataType = AttributeDataType.NUMBER; break; |
|
98 |
case "date": dataType = AttributeDataType.DATE; break; |
|
99 |
case "enum": dataType = AttributeDataType.ENUM; break; |
|
100 |
default: dataType = AttributeDataType.STRING; break; |
|
100 | 101 |
} |
101 | 102 |
graphManager.addAttributeType(attributeType.getString("name"), dataType, attributeType.getString("text")); |
102 | 103 |
} |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/loader/JSONConfigLoader.java | ||
---|---|---|
1 | 1 |
package cz.zcu.kiv.offscreen.graph.loader; |
2 | 2 |
|
3 |
import cz.zcu.kiv.offscreen.graph.AttributeType; |
|
3 |
import cz.zcu.kiv.offscreen.api.AttributeDataType; |
|
4 |
import cz.zcu.kiv.offscreen.api.AttributeType; |
|
4 | 5 |
import cz.zcu.kiv.offscreen.graph.EdgeArchetypeInfo; |
5 | 6 |
import cz.zcu.kiv.offscreen.graph.GraphManager; |
6 | 7 |
import cz.zcu.kiv.offscreen.graph.filter.*; |
... | ... | |
222 | 223 |
for (Object[] vertexAttributeFilterString : vertexAttributeFilterStrings) { |
223 | 224 |
int archetypeIndex = graphManager.getVertexArchetypeIndex(vertexAttributeFilterString[0].toString()); |
224 | 225 |
int attributeIndex = graphManager.getAttributeIndex(vertexAttributeFilterString[1].toString()); |
225 |
GraphManager.AttributeDataType type = graphManager.attributeTypes.get(attributeIndex).dataType;
|
|
226 |
AttributeDataType type = graphManager.attributeTypes.get(attributeIndex).dataType; |
|
226 | 227 |
switch (type) { |
227 | 228 |
case NUMBER: |
228 | 229 |
NumberAttributeFilter nf = (NumberAttributeFilter) vertexAttributeFilterString[2]; |
... | ... | |
253 | 254 |
for (Object[] edgeAttributeFilterString : edgeAttributeFilterStrings) { |
254 | 255 |
int archetypeIndex = graphManager.getEdgeArchetypeIndex(edgeAttributeFilterString[0].toString()); |
255 | 256 |
int attributeIndex = graphManager.getAttributeIndex(edgeAttributeFilterString[1].toString()); |
256 |
GraphManager.AttributeDataType type = graphManager.attributeTypes.get(attributeIndex).dataType;
|
|
257 |
AttributeDataType type = graphManager.attributeTypes.get(attributeIndex).dataType; |
|
257 | 258 |
switch (type) { |
258 | 259 |
case NUMBER: |
259 | 260 |
NumberAttributeFilter nf = (NumberAttributeFilter) edgeAttributeFilterString[2]; |
Také k dispozici: Unified diff
Backend refactor