Revize 9a88453d
Přidáno uživatelem Tomáš Šimandl před více než 6 roky(ů)
sources/src/main/java/cz/zcu/kiv/offscreen/data/efpportal/CocaexData.java | ||
---|---|---|
1 |
///** |
|
2 |
// * |
|
3 |
// */ |
|
4 |
//package cz.zcu.kiv.offscreen.data.efpportal; |
|
5 |
// |
|
6 |
//import java.util.HashMap; |
|
7 |
//import java.util.Map; |
|
8 |
// |
|
9 |
///** |
|
10 |
// * |
|
11 |
// * Representation of EFPPortal's connections . A connection consists of a provided and required features. |
|
12 |
// * |
|
13 |
// * @author Jiri Loudil |
|
14 |
// * |
|
15 |
// */ |
|
16 |
//public class CocaexData { |
|
17 |
// /** |
|
18 |
// * Map of all provided features. |
|
19 |
// */ |
|
20 |
// private Map<String, CocaexDataFeature> providedFeatures; |
|
21 |
// |
|
22 |
// /** |
|
23 |
// * Map of all required features. |
|
24 |
// */ |
|
25 |
// private Map<String, CocaexDataFeature> requiredFeatures; |
|
26 |
// |
|
27 |
// public CocaexData() { |
|
28 |
// this.providedFeatures = new HashMap<String, CocaexDataFeature>(); |
|
29 |
// this.requiredFeatures = new HashMap<String, CocaexDataFeature>(); |
|
30 |
// } |
|
31 |
// |
|
32 |
// /** |
|
33 |
// * @return the providedFeatures |
|
34 |
// */ |
|
35 |
// public Map<String, CocaexDataFeature> getProvidedFeatures() { |
|
36 |
// return providedFeatures; |
|
37 |
// } |
|
38 |
// |
|
39 |
// /** |
|
40 |
// * @return the importedFeatures |
|
41 |
// */ |
|
42 |
// public Map<String, CocaexDataFeature> getRequiredFeatures() { |
|
43 |
// return requiredFeatures; |
|
44 |
// } |
|
45 |
// |
|
46 |
//} |
sources/src/main/java/cz/zcu/kiv/offscreen/data/efpportal/CocaexDataEfp.java | ||
---|---|---|
1 |
//package cz.zcu.kiv.offscreen.data.efpportal; |
|
2 |
// |
|
3 |
//import cz.zcu.kiv.efps.comparator.result.EfpEvalResult.MatchingResult; |
|
4 |
//import cz.zcu.kiv.efps.types.datatypes.EfpValueType; |
|
5 |
// |
|
6 |
///** |
|
7 |
// * Holds EFP's data. |
|
8 |
// * |
|
9 |
// * @author Jiri Loudil |
|
10 |
// * |
|
11 |
// */ |
|
12 |
//public class CocaexDataEfp { |
|
13 |
// private String efpName; |
|
14 |
// private String efpValueTypeName; |
|
15 |
// private EfpValueType efpValue; |
|
16 |
// private MatchingResult typeError; |
|
17 |
// |
|
18 |
// /** |
|
19 |
// * @return the efpName |
|
20 |
// */ |
|
21 |
// public String getEfpName() { |
|
22 |
// return efpName; |
|
23 |
// } |
|
24 |
// /** |
|
25 |
// * @param efpName the efpName to set |
|
26 |
// */ |
|
27 |
// public void setEfpName(String efpName) { |
|
28 |
// this.efpName = efpName; |
|
29 |
// } |
|
30 |
// /** |
|
31 |
// * @return the efpValueTypeName |
|
32 |
// */ |
|
33 |
// public String getEfpValueTypeName() { |
|
34 |
// return efpValueTypeName; |
|
35 |
// } |
|
36 |
// /** |
|
37 |
// * @param efpValueTypeName the efpValueTypeName to set |
|
38 |
// */ |
|
39 |
// public void setEfpValueTypeName(String efpValueTypeName) { |
|
40 |
// this.efpValueTypeName = efpValueTypeName; |
|
41 |
// } |
|
42 |
// /** |
|
43 |
// * @return the efpValue |
|
44 |
// */ |
|
45 |
// public EfpValueType getEfpValue() { |
|
46 |
// return efpValue; |
|
47 |
// } |
|
48 |
// /** |
|
49 |
// * @param efpValue the efpValue to set |
|
50 |
// */ |
|
51 |
// public void setEfpValue(EfpValueType efpValue) { |
|
52 |
// this.efpValue = efpValue; |
|
53 |
// } |
|
54 |
// |
|
55 |
// /** |
|
56 |
// * @return the typeError |
|
57 |
// */ |
|
58 |
// public MatchingResult getTypeError() { |
|
59 |
// return typeError; |
|
60 |
// } |
|
61 |
// |
|
62 |
// /** |
|
63 |
// * @param typeError the typeError to set |
|
64 |
// */ |
|
65 |
// public void setTypeError(MatchingResult typeError) { |
|
66 |
// this.typeError = typeError; |
|
67 |
// } |
|
68 |
// |
|
69 |
//} |
sources/src/main/java/cz/zcu/kiv/offscreen/data/efpportal/CocaexDataFeature.java | ||
---|---|---|
1 |
//package cz.zcu.kiv.offscreen.data.efpportal; |
|
2 |
// |
|
3 |
//import java.util.ArrayList; |
|
4 |
//import java.util.List; |
|
5 |
// |
|
6 |
///** |
|
7 |
// * Holds feature's data. |
|
8 |
// * |
|
9 |
// * @author Jiri Loudil |
|
10 |
// * |
|
11 |
// */ |
|
12 |
//public class CocaexDataFeature { |
|
13 |
// private List<CocaexDataEfp> efps; |
|
14 |
// |
|
15 |
// public CocaexDataFeature() { |
|
16 |
// this.efps = new ArrayList<CocaexDataEfp>(); |
|
17 |
// } |
|
18 |
// |
|
19 |
// /** |
|
20 |
// * @return the efps |
|
21 |
// */ |
|
22 |
// public List<CocaexDataEfp> getEfps() { |
|
23 |
// return efps; |
|
24 |
// } |
|
25 |
// |
|
26 |
// /** |
|
27 |
// * @param efps the efps to set |
|
28 |
// */ |
|
29 |
// public void setEfps(List<CocaexDataEfp> efps) { |
|
30 |
// this.efps = efps; |
|
31 |
// } |
|
32 |
// |
|
33 |
//} |
sources/src/main/java/cz/zcu/kiv/offscreen/data/efpportal/CocaexWrapper.java | ||
---|---|---|
1 |
//package cz.zcu.kiv.offscreen.data.efpportal; |
|
2 |
// |
|
3 |
//import java.util.Map; |
|
4 |
// |
|
5 |
///** |
|
6 |
// * |
|
7 |
// * EFPPortal export data wrapper. Contains mappings for feature connection names and EFPs names. |
|
8 |
// * |
|
9 |
// * @author Jiri Loudil |
|
10 |
// * |
|
11 |
// */ |
|
12 |
//public class CocaexWrapper { |
|
13 |
// /** |
|
14 |
// * Feature names mapping. |
|
15 |
// */ |
|
16 |
// private Map<String, String> featureMappings; |
|
17 |
// |
|
18 |
// /** |
|
19 |
// * EFPs name s mapping. |
|
20 |
// */ |
|
21 |
// private Map<String, String> efpMappings; |
|
22 |
// |
|
23 |
// /** |
|
24 |
// * EFPPortal data with IDs instead of names for EFPs and Features. |
|
25 |
// */ |
|
26 |
// private Map<String, CocaexData> data; |
|
27 |
// |
|
28 |
// /** |
|
29 |
// * @return the featureMappings |
|
30 |
// */ |
|
31 |
// public Map<String, String> getFeatureMappings() { |
|
32 |
// return featureMappings; |
|
33 |
// } |
|
34 |
// /** |
|
35 |
// * @param featureMappings the featureMappings to set |
|
36 |
// */ |
|
37 |
// public void setFeatureMappings(Map<String, String> featureMappings) { |
|
38 |
// this.featureMappings = featureMappings; |
|
39 |
// } |
|
40 |
// /** |
|
41 |
// * @return the efpMappings |
|
42 |
// */ |
|
43 |
// public Map<String, String> getEfpMappings() { |
|
44 |
// return efpMappings; |
|
45 |
// } |
|
46 |
// /** |
|
47 |
// * @param efpMappings the efpMappings to set |
|
48 |
// */ |
|
49 |
// public void setEfpMappings(Map<String, String> efpMappings) { |
|
50 |
// this.efpMappings = efpMappings; |
|
51 |
// } |
|
52 |
// /** |
|
53 |
// * @return the data |
|
54 |
// */ |
|
55 |
// public Map<String, CocaexData> getData() { |
|
56 |
// return data; |
|
57 |
// } |
|
58 |
// /** |
|
59 |
// * @param data the data to set |
|
60 |
// */ |
|
61 |
// public void setData(Map<String, CocaexData> data) { |
|
62 |
// this.data = data; |
|
63 |
// } |
|
64 |
// |
|
65 |
// |
|
66 |
//} |
sources/src/main/java/cz/zcu/kiv/offscreen/efp/utils/JsonTransformer.java | ||
---|---|---|
1 |
//package cz.zcu.kiv.offscreen.efp.utils; |
|
2 |
// |
|
3 |
//import java.io.ByteArrayInputStream; |
|
4 |
//import java.io.IOException; |
|
5 |
//import java.util.zip.GZIPInputStream; |
|
6 |
// |
|
7 |
//import javax.servlet.http.HttpServletRequest; |
|
8 |
// |
|
9 |
//import org.apache.log4j.Logger; |
|
10 |
// |
|
11 |
//import net.sf.json.JSONObject; |
|
12 |
// |
|
13 |
//import org.apache.commons.codec.binary.Base64; |
|
14 |
//import org.apache.commons.io.IOUtils; |
|
15 |
// |
|
16 |
//import com.google.gson.Gson; |
|
17 |
//import com.google.gson.GsonBuilder; |
|
18 |
// |
|
19 |
//import cz.zcu.kiv.efps.types.datatypes.EfpValueType; |
|
20 |
//import cz.zcu.kiv.efps.types.serialisation.json.EfpValueTypeAdapter; |
|
21 |
//import cz.zcu.kiv.offscreen.api.GraphInterface; |
|
22 |
//import cz.zcu.kiv.offscreen.data.efpportal.CocaexWrapper; |
|
23 |
//import cz.zcu.kiv.offscreen.graph.GraphExport; |
|
24 |
//import cz.zcu.kiv.offscreen.graph.creator.EfpGraphTransfomer; |
|
25 |
// |
|
26 |
///** |
|
27 |
// * |
|
28 |
// * Transofma and decompress tools for incoming JSON. |
|
29 |
// * |
|
30 |
// * @author Jiri Loudil |
|
31 |
// * |
|
32 |
// */ |
|
33 |
//public class JsonTransformer { |
|
34 |
// private Logger logger = Logger.getLogger(JsonTransformer.class); |
|
35 |
// |
|
36 |
// /** |
|
37 |
// * |
|
38 |
// * Deserialize input JSON and transform to graph JSON. |
|
39 |
// * |
|
40 |
// * @param inputJSON |
|
41 |
// * @param request |
|
42 |
// * @return |
|
43 |
// * @throws IOException |
|
44 |
// */ |
|
45 |
// public String transformInputJSONToGraphJSON(String inputJSON, |
|
46 |
// HttpServletRequest request) throws IOException { |
|
47 |
// CocaexWrapper efpResults; |
|
48 |
// |
|
49 |
// GsonBuilder gsonBuilder = new GsonBuilder(); |
|
50 |
// // JSON deserializing adapter provided for EFP type classes |
|
51 |
// gsonBuilder.registerTypeAdapter(EfpValueType.class, |
|
52 |
// new EfpValueTypeAdapter()); |
|
53 |
// // JSON deserializing adapter for the Wrapper class |
|
54 |
// gsonBuilder.registerTypeAdapter(CocaexWrapper.class, |
|
55 |
// new WrapperDeserializer()); |
|
56 |
// Gson gson = gsonBuilder.create(); |
|
57 |
// |
|
58 |
// // decode + unzip received data |
|
59 |
// String data = decompress(inputJSON); |
|
60 |
// |
|
61 |
// // deserialize using deserializer adapters |
|
62 |
// efpResults = gson.fromJson(data, CocaexWrapper.class); |
|
63 |
// |
|
64 |
// request.setAttribute("efpPortalEfpNames", efpResults.getEfpMappings()); |
|
65 |
// |
|
66 |
// // transform received data to readable graph form |
|
67 |
// EfpGraphTransfomer transformer = new EfpGraphTransfomer(efpResults); |
|
68 |
// GraphInterface graph = transformer.transform(); |
|
69 |
// GraphExport export = new GraphExport(graph); |
|
70 |
// |
|
71 |
// // transform graph to JSON |
|
72 |
// JSONObject o = JSONObject.fromObject(export); |
|
73 |
// |
|
74 |
// return o.toString(); |
|
75 |
// } |
|
76 |
// |
|
77 |
// /** |
|
78 |
// * Decode and unzip a Base64 encoded GZIPed string. |
|
79 |
// * |
|
80 |
// * @param input |
|
81 |
// * @return |
|
82 |
// * @throws IOException |
|
83 |
// */ |
|
84 |
// private String decompress(String input) throws IOException { |
|
85 |
// logger.trace("ENTRY"); |
|
86 |
// String result = null; |
|
87 |
// |
|
88 |
// byte[] bytes = Base64.decodeBase64(input); |
|
89 |
// GZIPInputStream zi = null; |
|
90 |
// try { |
|
91 |
// zi = new GZIPInputStream(new ByteArrayInputStream(bytes)); |
|
92 |
// result = IOUtils.toString(zi); |
|
93 |
// } finally { |
|
94 |
// IOUtils.closeQuietly(zi); |
|
95 |
// } |
|
96 |
// logger.trace("EXIT"); |
|
97 |
// |
|
98 |
// return result; |
|
99 |
// } |
|
100 |
// |
|
101 |
//} |
sources/src/main/java/cz/zcu/kiv/offscreen/efp/utils/WrapperDeserializer.java | ||
---|---|---|
1 |
//package cz.zcu.kiv.offscreen.efp.utils; |
|
2 |
// |
|
3 |
//import java.lang.reflect.Type; |
|
4 |
//import java.util.HashMap; |
|
5 |
//import java.util.Map; |
|
6 |
// |
|
7 |
//import org.apache.log4j.Logger; |
|
8 |
// |
|
9 |
//import com.google.gson.Gson; |
|
10 |
//import com.google.gson.GsonBuilder; |
|
11 |
//import com.google.gson.JsonDeserializationContext; |
|
12 |
//import com.google.gson.JsonDeserializer; |
|
13 |
//import com.google.gson.JsonElement; |
|
14 |
//import com.google.gson.JsonObject; |
|
15 |
// |
|
16 |
//import cz.zcu.kiv.efps.types.datatypes.EfpValueType; |
|
17 |
//import cz.zcu.kiv.efps.types.serialisation.json.EfpValueTypeAdapter; |
|
18 |
//import cz.zcu.kiv.offscreen.data.efpportal.CocaexData; |
|
19 |
//import cz.zcu.kiv.offscreen.data.efpportal.CocaexWrapper; |
|
20 |
// |
|
21 |
///** |
|
22 |
// * |
|
23 |
// * CocaexWrapper class deserializer. |
|
24 |
// * |
|
25 |
// * @author Jiri Loudil |
|
26 |
// * |
|
27 |
// */ |
|
28 |
//public class WrapperDeserializer implements JsonDeserializer<CocaexWrapper> { |
|
29 |
// private Logger logger = Logger.getLogger(WrapperDeserializer.class); |
|
30 |
// |
|
31 |
// @Override |
|
32 |
// public CocaexWrapper deserialize(JsonElement json, Type typeOfT, |
|
33 |
// JsonDeserializationContext context) { |
|
34 |
// logger.trace("ENTRY"); |
|
35 |
// |
|
36 |
// GsonBuilder gsonBuilder = new GsonBuilder(); |
|
37 |
// // JSON deserializing adapter provided for EFP type classes |
|
38 |
// gsonBuilder.registerTypeAdapter(EfpValueType.class, |
|
39 |
// new EfpValueTypeAdapter()); |
|
40 |
// Gson gson = gsonBuilder.create(); |
|
41 |
// |
|
42 |
// CocaexWrapper wrapper = gson.fromJson(json, CocaexWrapper.class); |
|
43 |
// JsonObject jo = json.getAsJsonObject(); |
|
44 |
// |
|
45 |
// Map<String, String> featureMappings = new HashMap<String, String>(); |
|
46 |
// Map<String, String> efpMappings = new HashMap<String, String>(); |
|
47 |
// Map<String, CocaexData> data = new HashMap<String, CocaexData>(); |
|
48 |
// |
|
49 |
// // parse feature mappings |
|
50 |
// JsonObject featuresObject = jo.getAsJsonObject("featureMappings"); |
|
51 |
// for (Map.Entry<String, JsonElement> entry : featuresObject.entrySet()) { |
|
52 |
// featureMappings.put(entry.getKey(), entry.getValue().getAsString()); |
|
53 |
// } |
|
54 |
// |
|
55 |
// // parse efps mappings |
|
56 |
// JsonObject efpsObject = jo.getAsJsonObject("efpMappings"); |
|
57 |
// for (Map.Entry<String, JsonElement> entry : efpsObject.entrySet()) { |
|
58 |
// efpMappings.put(entry.getKey(), entry.getValue().getAsString()); |
|
59 |
// } |
|
60 |
// |
|
61 |
// // parse data |
|
62 |
// JsonObject dataObject = jo.getAsJsonObject("data"); |
|
63 |
// for (Map.Entry<String, JsonElement> entry : dataObject.entrySet()) { |
|
64 |
// data.put(entry.getKey(), (CocaexData) context.deserialize( |
|
65 |
// entry.getValue(), CocaexData.class)); |
|
66 |
// } |
|
67 |
// |
|
68 |
// // fill output structure |
|
69 |
// wrapper.setFeatureMappings(featureMappings); |
|
70 |
// wrapper.setEfpMappings(efpMappings); |
|
71 |
// wrapper.setData(data); |
|
72 |
// logger.trace("EXIT"); |
|
73 |
// |
|
74 |
// return wrapper; |
|
75 |
// } |
|
76 |
//} |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/creator/EfpGraphTransfomer.java | ||
---|---|---|
1 |
//package cz.zcu.kiv.offscreen.graph.creator; |
|
2 |
// |
|
3 |
//import java.util.ArrayList; |
|
4 |
//import java.util.HashMap; |
|
5 |
//import java.util.List; |
|
6 |
//import java.util.Map; |
|
7 |
// |
|
8 |
//import org.apache.log4j.Logger; |
|
9 |
// |
|
10 |
//import cz.zcu.kiv.efps.comparator.result.EfpEvalResult.MatchingResult; |
|
11 |
//import cz.zcu.kiv.offscreen.api.EdgeInterface; |
|
12 |
//import cz.zcu.kiv.offscreen.api.GraphInterface; |
|
13 |
//import cz.zcu.kiv.offscreen.api.VertexInterface; |
|
14 |
//import cz.zcu.kiv.offscreen.data.efpportal.CocaexData; |
|
15 |
//import cz.zcu.kiv.offscreen.data.efpportal.CocaexDataEfp; |
|
16 |
//import cz.zcu.kiv.offscreen.data.efpportal.CocaexDataFeature; |
|
17 |
//import cz.zcu.kiv.offscreen.data.efpportal.CocaexWrapper; |
|
18 |
//import cz.zcu.kiv.offscreen.graph.EdgeEfp; |
|
19 |
//import cz.zcu.kiv.offscreen.graph.GraphImpl; |
|
20 |
//import cz.zcu.kiv.offscreen.graph.VertexEfp; |
|
21 |
//import cz.zcu.kiv.offscreen.graph.efp.EfpComparison; |
|
22 |
//import cz.zcu.kiv.offscreen.graph.efp.EfpFeature; |
|
23 |
// |
|
24 |
///** |
|
25 |
// * |
|
26 |
// * Transforms data obtained in form of Map<String, CocaexData> to |
|
27 |
// * cz.zcu.kiv.offscreen.api.GraphInterface. |
|
28 |
// * |
|
29 |
// * @author Jiri Loudil |
|
30 |
// * |
|
31 |
// */ |
|
32 |
//public class EfpGraphTransfomer { |
|
33 |
// |
|
34 |
// private final String DELIMITER = ";"; |
|
35 |
// |
|
36 |
// /** |
|
37 |
// * Output data format. |
|
38 |
// */ |
|
39 |
// private GraphInterface graph = null; |
|
40 |
// |
|
41 |
// /** |
|
42 |
// * Input data format. |
|
43 |
// */ |
|
44 |
// private Map<String, CocaexData> resultData = null; |
|
45 |
// |
|
46 |
// private Map<String, String> resultFeaturesMapping = null; |
|
47 |
// |
|
48 |
// private Map<String, String> resultEfpsMapping = null; |
|
49 |
// |
|
50 |
// /** |
|
51 |
// * Already used vertices. |
|
52 |
// */ |
|
53 |
// private Map<String, VertexInterface> vertexMap; |
|
54 |
// |
|
55 |
// /** |
|
56 |
// * Already used features. |
|
57 |
// */ |
|
58 |
// private Map<String, EfpFeature> featureMap; |
|
59 |
// |
|
60 |
// /** |
|
61 |
// * Logging. |
|
62 |
// */ |
|
63 |
// private Logger logger = Logger.getLogger(EfpGraphTransfomer.class); |
|
64 |
// |
|
65 |
// /** |
|
66 |
// * New transformer from input data. |
|
67 |
// * |
|
68 |
// * @param efpportalResultsWrapper |
|
69 |
// * Input data in from of EfpPortal app. |
|
70 |
// */ |
|
71 |
// public EfpGraphTransfomer(CocaexWrapper efpportalResultsWrapper) { |
|
72 |
// logger.trace("ENTRY"); |
|
73 |
// this.graph = new GraphImpl(); |
|
74 |
// |
|
75 |
// this.resultData = efpportalResultsWrapper.getData(); |
|
76 |
// this.resultEfpsMapping = efpportalResultsWrapper.getEfpMappings(); |
|
77 |
// this.resultFeaturesMapping = efpportalResultsWrapper |
|
78 |
// .getFeatureMappings(); |
|
79 |
// |
|
80 |
// this.vertexMap = new HashMap<String, VertexInterface>(); |
|
81 |
// this.featureMap = new HashMap<String, EfpFeature>(); |
|
82 |
// |
|
83 |
// logger.trace("EXIT"); |
|
84 |
// } |
|
85 |
// |
|
86 |
// /** |
|
87 |
// * Generates the graph with vertices and edges. |
|
88 |
// * |
|
89 |
// * @return graph |
|
90 |
// */ |
|
91 |
// public GraphInterface transform() { |
|
92 |
// logger.trace("ENTRY"); |
|
93 |
// this.generateVertices(); |
|
94 |
// this.generateEdges(); |
|
95 |
// |
|
96 |
// // set proper feature and efp names |
|
97 |
// this.setNamesInsteadOfNumbers(); |
|
98 |
// logger.trace("EXIT"); |
|
99 |
// |
|
100 |
// return this.graph; |
|
101 |
// } |
|
102 |
// |
|
103 |
// /** |
|
104 |
// * Substitute ID for the proper name string. |
|
105 |
// */ |
|
106 |
// private void setNamesInsteadOfNumbers() { |
|
107 |
// logger.trace("ENTRY"); |
|
108 |
// |
|
109 |
// List<EdgeInterface> edges = graph.getEdges(); |
|
110 |
// |
|
111 |
// for (EdgeInterface edgeInterface : edges) { |
|
112 |
// ArrayList<EfpFeature> features = ((EdgeEfp) edgeInterface) |
|
113 |
// .getFeatures(); |
|
114 |
// |
|
115 |
// for (EfpFeature efpFeature : features) { |
|
116 |
// // substitute ID for the true name from the feature mapping |
|
117 |
// String tmpFeatureName = resultFeaturesMapping.get(efpFeature.getName()); |
|
118 |
// |
|
119 |
// efpFeature.setName(tmpFeatureName.split(DELIMITER)[1]); |
|
120 |
// |
|
121 |
// ArrayList<EfpComparison> efps = efpFeature.getEfps(); |
|
122 |
// |
|
123 |
// for (EfpComparison efpComparison : efps) { |
|
124 |
// // substitute ID for the true name from the efps mapping |
|
125 |
// efpComparison.setEfpName(resultEfpsMapping |
|
126 |
// .get(efpComparison.getEfpName())); |
|
127 |
// } |
|
128 |
// } |
|
129 |
// } |
|
130 |
// |
|
131 |
// logger.trace("EXIT"); |
|
132 |
// } |
|
133 |
// |
|
134 |
// /** |
|
135 |
// * Generate vertices for this graph. |
|
136 |
// */ |
|
137 |
// private void generateVertices() { |
|
138 |
// logger.trace("ENTRY"); |
|
139 |
// |
|
140 |
// int id = 0; |
|
141 |
// VertexEfp vertex; |
|
142 |
// |
|
143 |
// for (Map.Entry<String, CocaexData> tmpData : resultData.entrySet()) { |
|
144 |
// id++; |
|
145 |
// |
|
146 |
// vertex = new VertexEfp(id, tmpData.getKey(), tmpData.getKey()); |
|
147 |
// |
|
148 |
// this.graph.addVertex(tmpData.getKey(), vertex); |
|
149 |
// this.vertexMap.put(tmpData.getKey(), vertex); |
|
150 |
// } |
|
151 |
// |
|
152 |
// logger.trace("EXIT"); |
|
153 |
// } |
|
154 |
// |
|
155 |
// /** |
|
156 |
// * Generate edges for this graph. |
|
157 |
// */ |
|
158 |
// private void generateEdges() { |
|
159 |
// logger.trace("ENTRY"); |
|
160 |
// |
|
161 |
// int id = 0; |
|
162 |
// String from, to; |
|
163 |
// CocaexData currentEvaluatedVertexData; |
|
164 |
// |
|
165 |
// for (Map.Entry<String, VertexInterface> currentVertex : vertexMap |
|
166 |
// .entrySet()) { |
|
167 |
// currentEvaluatedVertexData = resultData.get(currentVertex.getKey()); |
|
168 |
// |
|
169 |
// to = currentVertex.getKey(); |
|
170 |
// |
|
171 |
// // all required features FROM |
|
172 |
// for (Map.Entry<String, CocaexDataFeature> tmpRequired : currentEvaluatedVertexData |
|
173 |
// .getRequiredFeatures().entrySet()) { |
|
174 |
// |
|
175 |
// String requiredFeatureName = this.resultFeaturesMapping |
|
176 |
// .get(tmpRequired.getKey()); |
|
177 |
// |
|
178 |
// // get feature name, its first part is component name |
|
179 |
// String[] requiredSplits = requiredFeatureName.split(DELIMITER); |
|
180 |
// |
|
181 |
// // not-connected ones are left over |
|
182 |
// if (!requiredSplits[0].isEmpty()) { |
|
183 |
// |
|
184 |
// // vertex from == vertex to -> we dont want that... |
|
185 |
// if (requiredSplits[0].equals(currentVertex.getKey())) { |
|
186 |
// continue; |
|
187 |
// } |
|
188 |
// |
|
189 |
// // find corresponding feature on the TO vertex |
|
190 |
// CocaexData otherVertexData = resultData |
|
191 |
// .get(requiredSplits[0]); |
|
192 |
// CocaexDataFeature otherVertexFeature = null; |
|
193 |
// |
|
194 |
// // go through all features of the TO |
|
195 |
// for (Map.Entry<String, CocaexDataFeature> tmpProvided : otherVertexData |
|
196 |
// .getProvidedFeatures().entrySet()) { |
|
197 |
// String providedFeatureName = this.resultFeaturesMapping |
|
198 |
// .get(tmpProvided.getKey()); |
|
199 |
// |
|
200 |
// String[] providedSplits = providedFeatureName |
|
201 |
// .split(DELIMITER); |
|
202 |
// |
|
203 |
// // not-connected ones are left over |
|
204 |
// if (providedSplits[0].isEmpty()) { |
|
205 |
// continue; |
|
206 |
// } |
|
207 |
// |
|
208 |
// // found matching feature between TO and FROM |
|
209 |
// if (providedSplits[0].equals(currentVertex.getKey()) |
|
210 |
// && providedSplits[1].equals(requiredSplits[1])) { |
|
211 |
// otherVertexFeature = tmpProvided.getValue(); |
|
212 |
// } |
|
213 |
// } |
|
214 |
// |
|
215 |
// from = requiredSplits[0]; |
|
216 |
// |
|
217 |
// EdgeEfp edge = findEdgeInGraph(from, to); |
|
218 |
// |
|
219 |
// // add new edge |
|
220 |
// if (edge == null) { |
|
221 |
// edge = new EdgeEfp(++id, from, to); |
|
222 |
// // from to |
|
223 |
// checkAddEdgeFeature(tmpRequired.getValue(), |
|
224 |
// otherVertexFeature, tmpRequired.getKey(), edge); |
|
225 |
// |
|
226 |
// this.graph.addEdge(edge); |
|
227 |
// } else { |
|
228 |
// // add a feature to an old edge only |
|
229 |
// checkAddEdgeFeature(tmpRequired.getValue(), |
|
230 |
// otherVertexFeature, tmpRequired.getKey(), edge); |
|
231 |
// } |
|
232 |
// } |
|
233 |
// |
|
234 |
// } |
|
235 |
// } |
|
236 |
// |
|
237 |
// logger.trace("EXIT"); |
|
238 |
// } |
|
239 |
// |
|
240 |
// /** |
|
241 |
// * |
|
242 |
// * Find an existing edge in graph. |
|
243 |
// * |
|
244 |
// * @param from |
|
245 |
// * Name of start vertex. |
|
246 |
// * @param to |
|
247 |
// * name of end vertex. |
|
248 |
// * @return Null if not found, edge otherwise. |
|
249 |
// */ |
|
250 |
// private EdgeEfp findEdgeInGraph(String from, String to) { |
|
251 |
// logger.trace("ENTRY"); |
|
252 |
// List<EdgeInterface> tmpEdges = this.graph.getEdges(); |
|
253 |
// |
|
254 |
// for (EdgeInterface edge : tmpEdges) { |
|
255 |
// // found old edge |
|
256 |
// if (edge.getFrom().equals(from) && edge.getTo().equals(to)) { |
|
257 |
// logger.trace("EXIT"); |
|
258 |
// return (EdgeEfp) edge; |
|
259 |
// } |
|
260 |
// } |
|
261 |
// |
|
262 |
// logger.trace("EXIT"); |
|
263 |
// return null; |
|
264 |
// } |
|
265 |
// |
|
266 |
// /** |
|
267 |
// * |
|
268 |
// * Check and add feature to edge. |
|
269 |
// * |
|
270 |
// * @param requiredFeature |
|
271 |
// * Required feature with EFPs. |
|
272 |
// * @param providedFeature |
|
273 |
// * Provided feature with EFPs. |
|
274 |
// * @param name |
|
275 |
// * Feature name. |
|
276 |
// * @param edge |
|
277 |
// * Edge where the feature belongs. |
|
278 |
// */ |
|
279 |
// private void checkAddEdgeFeature(CocaexDataFeature requiredFeature, |
|
280 |
// CocaexDataFeature providedFeature, String name, EdgeEfp edge) { |
|
281 |
// logger.trace("ENTRY"); |
|
282 |
// EfpFeature tmpFeature = null; |
|
283 |
// |
|
284 |
// // find out if the edge already has a features like the added one |
|
285 |
// for (EfpFeature oldFeature : edge.getFeatures()) { |
|
286 |
// // the edge contains the feature already |
|
287 |
// if (oldFeature.getName().equals(name)) { |
|
288 |
// tmpFeature = oldFeature; |
|
289 |
// break; |
|
290 |
// } |
|
291 |
// } |
|
292 |
// |
|
293 |
// // an old feature |
|
294 |
// if (tmpFeature != null) { |
|
295 |
// tmpFeature = featureMap.get(name); |
|
296 |
// |
|
297 |
// processEfpsToFeature(requiredFeature, providedFeature, tmpFeature, |
|
298 |
// edge); |
|
299 |
// } else { // add new feature to edge |
|
300 |
// tmpFeature = new EfpFeature(name); |
|
301 |
// |
|
302 |
// // preset the OK state |
|
303 |
// tmpFeature.setFeatureStatus(MatchingResult.OK.toString()); |
|
304 |
// |
|
305 |
// processEfpsToFeature(requiredFeature, providedFeature, tmpFeature, |
|
306 |
// edge); |
|
307 |
// |
|
308 |
// edge.getFeatures().add(tmpFeature); |
|
309 |
// featureMap.put(name, tmpFeature); |
|
310 |
// } |
|
311 |
// logger.trace("EXIT"); |
|
312 |
// } |
|
313 |
// |
|
314 |
// /** |
|
315 |
// * |
|
316 |
// * Prepare process of adding EFP values to existing feature. |
|
317 |
// * |
|
318 |
// * @param requiredFeature |
|
319 |
// * Required feature with EFPs. |
|
320 |
// * @param providedFeature |
|
321 |
// * Provided feature with EFPs. |
|
322 |
// * @param feature |
|
323 |
// * Existing feature. |
|
324 |
// * @param edge |
|
325 |
// * Edge where the EFPs with feature belong. |
|
326 |
// */ |
|
327 |
// private void processEfpsToFeature(CocaexDataFeature requiredFeature, |
|
328 |
// CocaexDataFeature providedFeature, EfpFeature feature, EdgeEfp edge) { |
|
329 |
// logger.trace("ENTRY"); |
|
330 |
// |
|
331 |
// MatchingResult result = checkAddFeatureEfp(requiredFeature, |
|
332 |
// providedFeature, feature); |
|
333 |
// |
|
334 |
// if (!result.equals(MatchingResult.OK)) { |
|
335 |
// edge.setEdgeStatusOk(false); |
|
336 |
// feature.setFeatureStatus(result.toString()); |
|
337 |
// } |
|
338 |
// |
|
339 |
// logger.trace("EXIT"); |
|
340 |
// } |
|
341 |
// |
|
342 |
// /** |
|
343 |
// * |
|
344 |
// * Check and add EFPs to an existing feature. |
|
345 |
// * |
|
346 |
// * @param requiredFeature |
|
347 |
// * Required feature with EFPs. |
|
348 |
// * @param providedFeature |
|
349 |
// * Provided feature with EFPs. |
|
350 |
// * @param feature |
|
351 |
// * Existing feature. |
|
352 |
// * @return Result of EFPs comparison. OK/MISSING/ERROR |
|
353 |
// */ |
|
354 |
// private MatchingResult checkAddFeatureEfp( |
|
355 |
// CocaexDataFeature requiredFeature, |
|
356 |
// CocaexDataFeature providedFeature, EfpFeature feature) { |
|
357 |
// logger.trace("ENTRY"); |
|
358 |
// final String defaultValue = "No value"; |
|
359 |
// |
|
360 |
// MatchingResult output = MatchingResult.OK; |
|
361 |
// |
|
362 |
// // all EFPs bound to this feature |
|
363 |
// for (int i = 0; i < requiredFeature.getEfps().size(); i++) { |
|
364 |
// EfpComparison efpCmp = new EfpComparison(); |
|
365 |
// |
|
366 |
// CocaexDataEfp firstEfp = requiredFeature.getEfps().get(i); |
|
367 |
// CocaexDataEfp secondEfp = providedFeature.getEfps().get(i); |
|
368 |
// |
|
369 |
// // set real values |
|
370 |
// if (firstEfp.getEfpValue() != null) { |
|
371 |
// efpCmp.setLeftEfpValue(firstEfp.getEfpValue().toString()); |
|
372 |
// } else { |
|
373 |
// efpCmp.setLeftEfpValue(defaultValue); |
|
374 |
// } |
|
375 |
// |
|
376 |
// if (secondEfp.getEfpValue() != null) { |
|
377 |
// efpCmp.setRightEfpValue(secondEfp.getEfpValue().toString()); |
|
378 |
// } else { |
|
379 |
// efpCmp.setRightEfpValue(defaultValue); |
|
380 |
// } |
|
381 |
// |
|
382 |
// efpCmp.setTypeName(firstEfp.getEfpValueTypeName()); |
|
383 |
// efpCmp.setEfpName(firstEfp.getEfpName()); |
|
384 |
// efpCmp.setComparisonStatus(firstEfp.getTypeError().name()); |
|
385 |
// |
|
386 |
// // at least one efp is not OK |
|
387 |
// if (!firstEfp.getTypeError().equals(MatchingResult.OK)) { |
|
388 |
// output = firstEfp.getTypeError(); |
|
389 |
// } |
|
390 |
// |
|
391 |
// feature.getEfps().add(efpCmp); |
|
392 |
// } |
|
393 |
// logger.trace("EXIT"); |
|
394 |
// |
|
395 |
// return output; |
|
396 |
// } |
|
397 |
//} |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/creator/GraphGenerator.java | ||
---|---|---|
1 |
//package cz.zcu.kiv.offscreen.graph.creator; |
|
2 |
// |
|
3 |
//import cz.zcu.kiv.offscreen.api.EdgeInterface; |
|
4 |
//import cz.zcu.kiv.offscreen.api.GraphInterface; |
|
5 |
//import cz.zcu.kiv.offscreen.api.VertexInterface; |
|
6 |
//import cz.zcu.kiv.offscreen.graph.EdgeImpl; |
|
7 |
//import cz.zcu.kiv.offscreen.graph.GraphImpl; |
|
8 |
//import cz.zcu.kiv.offscreen.graph.VertexImpl; |
|
9 |
//import java.security.InvalidParameterException; |
|
10 |
//import java.util.Random; |
|
11 |
//import org.apache.log4j.Logger; |
|
12 |
// |
|
13 |
///** |
|
14 |
// * @author Jindra Pavlíková <jindra.pav2@seznam.cz> |
|
15 |
// */ |
|
16 |
//public class GraphGenerator { |
|
17 |
// |
|
18 |
// private final int COUNT_OF_VERTICES; |
|
19 |
// private final int COUNT_OF_EDGES; |
|
20 |
// private GraphInterface graph; |
|
21 |
// private boolean[][] conectionGraph; |
|
22 |
// |
|
23 |
// private Logger logger = Logger.getLogger(GraphGenerator.class); |
|
24 |
// |
|
25 |
// public GraphGenerator(int countOfVertices, int countOfEdges) { |
|
26 |
// logger.trace("ENTRY"); |
|
27 |
// if (countOfVertices <= 0 || countOfEdges <= 0 |
|
28 |
// || countOfEdges > (countOfVertices * countOfVertices - countOfVertices)) { |
|
29 |
// throw new InvalidParameterException("Count of edges is greater then count of possible edges."); |
|
30 |
// } |
|
31 |
// this.COUNT_OF_VERTICES = countOfVertices; |
|
32 |
// this.COUNT_OF_EDGES = countOfEdges; |
|
33 |
// this.graph = new GraphImpl(); |
|
34 |
// this.conectionGraph = new boolean[this.COUNT_OF_VERTICES][this.COUNT_OF_VERTICES]; |
|
35 |
// logger.trace("EXIT"); |
|
36 |
// } |
|
37 |
// |
|
38 |
// /** |
|
39 |
// * This method creates the vertices and adds them to the graph. |
|
40 |
// */ |
|
41 |
// private void generateVertices() { |
|
42 |
// logger.trace("ENTRY"); |
|
43 |
// VertexInterface vertex; |
|
44 |
// String name; |
|
45 |
// |
|
46 |
// for (int i = 0; i < this.COUNT_OF_VERTICES; i++) { |
|
47 |
// name = "vertex " + (i + 1); |
|
48 |
// vertex = new VertexImpl((i + 1), name, name); |
|
49 |
// this.graph.addVertex(name, vertex); |
|
50 |
// } |
|
51 |
// logger.trace("EXIT"); |
|
52 |
// } |
|
53 |
// |
|
54 |
// /** |
|
55 |
// * Generates edges between randomly selected vertices and adds them to the |
|
56 |
// * graph. |
|
57 |
// */ |
|
58 |
// private void generateEdges() { |
|
59 |
// logger.trace("ENTRY"); |
|
60 |
// Random rnd = new Random(10); |
|
61 |
// int v1, v2; |
|
62 |
// EdgeInterface edge; |
|
63 |
// VertexImpl vertex1, vertex2; |
|
64 |
// for (int i = 0; i < this.COUNT_OF_EDGES; i++) { |
|
65 |
// |
|
66 |
// do { |
|
67 |
// v1 = rnd.nextInt(this.COUNT_OF_VERTICES); |
|
68 |
// v2 = rnd.nextInt(this.COUNT_OF_VERTICES); |
|
69 |
// } while (v1 == v2 || this.conectionGraph[v1][v2] == true); |
|
70 |
// |
|
71 |
// this.conectionGraph[v1][v2] = true; |
|
72 |
// |
|
73 |
// vertex1 = (VertexImpl) this.graph.getVertices().get("vertex " + (v1 + 1)); |
|
74 |
// vertex2 = (VertexImpl) this.graph.getVertices().get("vertex " + (v2 + 1)); |
|
75 |
// edge = new EdgeImpl(i + 1, vertex1.getName(), vertex2.getName(), true, ""); |
|
76 |
// this.graph.addEdge(edge); |
|
77 |
//// vertex1.addEdge(edge); |
|
78 |
//// vertex2.addEdge(edge); |
|
79 |
// |
|
80 |
// } |
|
81 |
// logger.trace("EXIT"); |
|
82 |
// } |
|
83 |
// |
|
84 |
// /** |
|
85 |
// * Generates the graph with vertices and edges. |
|
86 |
// * |
|
87 |
// * @return graph |
|
88 |
// */ |
|
89 |
// public GraphInterface generate() { |
|
90 |
// logger.trace("ENTRY"); |
|
91 |
// generateVertices(); |
|
92 |
// generateEdges(); |
|
93 |
// logger.trace("EXIT"); |
|
94 |
// return this.graph; |
|
95 |
// } |
|
96 |
//} |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/creator/GraphMaker.java | ||
---|---|---|
1 |
//package cz.zcu.kiv.offscreen.graph.creator; |
|
2 |
// |
|
3 |
//import cz.zcu.kiv.ccu.ApiCmpStateResult; |
|
4 |
//import cz.zcu.kiv.ccu.ApiInterCompatibilityResult; |
|
5 |
//import cz.zcu.kiv.jacc.cmp.JComparator; |
|
6 |
//import cz.zcu.kiv.jacc.javatypes.*; |
|
7 |
//import cz.zcu.kiv.offscreen.api.GraphInterface; |
|
8 |
//import cz.zcu.kiv.offscreen.api.VertexInterface; |
|
9 |
//import cz.zcu.kiv.offscreen.graph.EdgeImpl; |
|
10 |
//import cz.zcu.kiv.offscreen.graph.GraphImpl; |
|
11 |
//import cz.zcu.kiv.offscreen.graph.VertexImpl; |
|
12 |
//import cz.zcu.kiv.typescmp.CmpResult; |
|
13 |
//import cz.zcu.kiv.typescmp.CmpResultNode; |
|
14 |
//import cz.zcu.kiv.typescmp.CorrectionStrategy; |
|
15 |
// |
|
16 |
//import org.apache.log4j.Logger; |
|
17 |
//import org.json.JSONArray; |
|
18 |
//import org.json.JSONObject; |
|
19 |
// |
|
20 |
//import java.io.File; |
|
21 |
//import java.io.IOException; |
|
22 |
//import java.io.InputStream; |
|
23 |
//import java.util.*; |
|
24 |
// |
|
25 |
///** |
|
26 |
// * This class provides creation graph of the loaded bundle. |
|
27 |
// * |
|
28 |
// * @author Jindra Pavlíková <jindra.pav2@seznam.cz> |
|
29 |
// */ |
|
30 |
//public class GraphMaker { |
|
31 |
// |
|
32 |
// private GraphInterface graph; |
|
33 |
// private Logger logger = Logger.getLogger(GraphMaker.class); |
|
34 |
// private Map<String, VertexInterface> vertexMap; |
|
35 |
// private String fileLocation; |
|
36 |
// private int level; |
|
37 |
// |
|
38 |
// private ApiInterCompatibilityResult comparisonResult; |
|
39 |
// private File[] uploadedFiles; |
|
40 |
// private Properties jaccMessages; |
|
41 |
// |
|
42 |
// private static final String NOT_FOUND = "NOT_FOUND"; |
|
43 |
// |
|
44 |
// public GraphMaker(String fileLocation, ApiInterCompatibilityResult comparisonResult, File[] uploadedFiles) throws IOException { |
|
45 |
// logger.trace("ENTRY"); |
|
46 |
// this.graph = new GraphImpl(); |
|
47 |
// this.fileLocation = fileLocation; |
|
48 |
// |
|
49 |
// this.uploadedFiles = uploadedFiles; |
|
50 |
// this.comparisonResult = comparisonResult; |
|
51 |
// logger.trace("EXIT"); |
|
52 |
// |
|
53 |
// jaccMessages = new Properties(); |
|
54 |
// InputStream in = null; |
|
55 |
// try { |
|
56 |
// in = JComparator.class.getResourceAsStream("messages.properties"); |
|
57 |
// jaccMessages.load(in); |
|
58 |
// } catch (IOException e) { |
|
59 |
// logger.trace(e); |
|
60 |
// } finally { |
|
61 |
// if (in != null) { |
|
62 |
// try { |
|
63 |
// in.close(); |
|
64 |
// } catch (IOException e) { |
|
65 |
// logger.trace(e); |
|
66 |
// } |
|
67 |
// } |
|
68 |
// } |
|
69 |
// } |
|
70 |
// |
|
71 |
// /** |
|
72 |
// * This method creates the vertices and adds them to the graph. |
|
73 |
// */ |
|
74 |
// private void generateVertices() { |
|
75 |
// logger.trace("ENTRY"); |
|
76 |
// |
|
77 |
// VertexImpl vertex; |
|
78 |
// String name; |
|
79 |
// String symbolicName; |
|
80 |
// int id = 0; |
|
81 |
// this.vertexMap = new HashMap<>(); |
|
82 |
// |
|
83 |
// for (File origin : this.uploadedFiles) { |
|
84 |
// id++; |
|
85 |
// symbolicName = createSymbolicName(origin.toString()); |
|
86 |
// name = origin.getName(); |
|
87 |
// vertex = new VertexImpl(id, name, symbolicName); |
|
88 |
// |
|
89 |
// this.vertexMap.put(symbolicName, vertex); |
|
90 |
// this.graph.addVertex(symbolicName, vertex); |
|
91 |
// } |
|
92 |
// |
|
93 |
// symbolicName = createSymbolicName(NOT_FOUND); |
|
94 |
// vertex = new VertexImpl(++id, NOT_FOUND, symbolicName); |
|
95 |
// |
|
96 |
// this.vertexMap.put(symbolicName, vertex); |
|
97 |
// this.graph.addVertex(symbolicName, vertex); |
|
98 |
// |
|
99 |
// logger.trace("EXIT"); |
|
100 |
// } |
|
101 |
// |
|
102 |
// /** |
|
103 |
// * This method creates the edges and adds them to the graph. Currently, only incompatible edges are created. |
|
104 |
// */ |
|
105 |
// private void generateEdges() { |
|
106 |
// logger.trace("ENTRY"); |
|
107 |
// |
|
108 |
// int id = 0; |
|
109 |
// |
|
110 |
// // cyklus pres nekompatibilni komponenty (komponenta = jar soubor) |
|
111 |
// Set<String> components = comparisonResult.getOriginsImportingIncompatibilities(); |
|
112 |
// for (String component : components) { |
|
113 |
// String firstOrigin = ""; |
|
114 |
// String secondOrigin = ""; |
|
115 |
// String firstOriginNF = ""; |
|
116 |
// String secondOriginNF = ""; |
|
117 |
// |
|
118 |
// JSONArray incompatibleInfoJSON = new JSONArray(); |
|
119 |
// JSONArray notFoundInfoJSON = new JSONArray(); |
|
120 |
// |
|
121 |
// // cyklus pres nekompatibilni tridy |
|
122 |
// Set<JClass> incompatibleClasses = comparisonResult.getClassesImportingIncompatibilities(component); |
|
123 |
// for (JClass incompatibleClass : incompatibleClasses) { |
|
124 |
// JSONArray incompatibilitiesJson = new JSONArray(); |
|
125 |
// JSONArray missingClassesJson = new JSONArray(); |
|
126 |
// |
|
127 |
// // cyklus pres samotne nekompatibility |
|
128 |
// Set<ApiCmpStateResult> apiCmpResults = comparisonResult.getIncompatibleResults(incompatibleClass, component); |
|
129 |
// for (ApiCmpStateResult apiCmpResult : apiCmpResults) { |
|
130 |
// this.level = 0; |
|
131 |
// |
|
132 |
// CmpResult<File> cmpResult = apiCmpResult.getResult(); |
|
133 |
// |
|
134 |
// if (cmpResult.getSecondObject() != null) { |
|
135 |
// List<CmpResultNode> children = cmpResult.getChildren(); |
|
136 |
// for (CmpResultNode child : children) { |
|
137 |
// incompatibilitiesJson.put(findIncompatibilityCause(child, "")); |
|
138 |
// } |
|
139 |
// |
|
140 |
// if (firstOrigin.equals("") && secondOrigin.equals("")) { |
|
141 |
// firstOrigin = cmpResult.getFirstObject().getName(); |
|
142 |
// secondOrigin = cmpResult.getSecondObject().getName(); |
|
143 |
// } |
|
144 |
// |
|
145 |
// } else { |
|
146 |
// List<CmpResultNode> children = cmpResult.getChildren(); |
|
147 |
// for (CmpResultNode child : children) { |
|
148 |
// missingClassesJson.put(findIncompatibilityCause(child, "")); |
|
149 |
// } |
|
150 |
// |
|
151 |
// if (firstOriginNF.equals("") && secondOriginNF.equals("")) { |
|
152 |
// firstOriginNF = cmpResult.getFirstObject().getName(); |
|
153 |
// secondOriginNF = NOT_FOUND; |
|
154 |
// } |
|
155 |
// } |
|
156 |
// } |
|
157 |
// |
|
158 |
// // incompatible class |
|
159 |
// JSONObject incompatibleClassJson = new JSONObject(); |
|
160 |
// incompatibleClassJson.put("causedBy", incompatibleClass.getName()); |
|
161 |
// incompatibleClassJson.put("incomps", incompatibilitiesJson); |
|
162 |
// |
|
163 |
// incompatibleInfoJSON.put(incompatibleClassJson); |
|
164 |
// |
|
165 |
// // not found class |
|
166 |
// JSONObject notFoundClassJson = new JSONObject(); |
|
167 |
// notFoundClassJson.put("causedBy", incompatibleClass.getName()); |
|
168 |
// notFoundClassJson.put("incomps", missingClassesJson); |
|
169 |
// |
|
170 |
// notFoundInfoJSON.put(notFoundClassJson); |
|
171 |
// } |
|
172 |
// |
|
173 |
// if (!firstOrigin.equals("")) { |
|
174 |
// id++; |
|
175 |
// EdgeImpl edge = new EdgeImpl(id, createSymbolicName(firstOrigin), createSymbolicName(secondOrigin), false, incompatibleInfoJSON.toString()); |
|
176 |
// this.graph.addEdge(edge); |
|
177 |
// } |
|
178 |
// |
|
179 |
// if (!firstOriginNF.equals("")) { |
|
180 |
// id++; |
|
181 |
// EdgeImpl edge = new EdgeImpl(id, createSymbolicName(secondOriginNF), createSymbolicName(firstOriginNF), false, notFoundInfoJSON.toString()); |
|
182 |
// this.graph.addEdge(edge); |
|
183 |
// } |
|
184 |
// } |
|
185 |
// |
|
186 |
// logger.trace("EXIT"); |
|
187 |
// } |
|
188 |
// |
|
189 |
// /** |
|
190 |
// * Create symbolic name. |
|
191 |
// * |
|
192 |
// * @param origin |
|
193 |
// * @return Symbolic name. |
|
194 |
// */ |
|
195 |
// private String createSymbolicName(String origin) { |
|
196 |
// String location = this.fileLocation.replace("/", File.separator) + File.separator; |
|
197 |
// |
|
198 |
// return "vertex_" + origin.replace(location, ""); |
|
199 |
// } |
|
200 |
// |
|
201 |
// /** |
|
202 |
// * Generates the graph with vertices and edges. |
|
203 |
// * |
|
204 |
// * @return graph |
|
205 |
// */ |
|
206 |
// public GraphInterface generate() { |
|
207 |
// logger.trace("ENTRY"); |
|
208 |
// |
|
209 |
// this.generateVertices(); |
|
210 |
// this.generateEdges(); |
|
211 |
// |
|
212 |
// logger.trace("EXIT"); |
|
213 |
// |
|
214 |
// return this.graph; |
|
215 |
// } |
|
216 |
// |
|
217 |
// /** |
|
218 |
// * Recursive function for traversing tree with incompatibility information. Creates object serializable to JSON. |
|
219 |
// * |
|
220 |
// * @param cmpResultNode |
|
221 |
// * @param corrStrategy |
|
222 |
// */ |
|
223 |
// public JSONObject findIncompatibilityCause(CmpResultNode cmpResultNode, String corrStrategy) { |
|
224 |
// Object o = cmpResultNode.getResult().getFirstObject(); |
|
225 |
// |
|
226 |
// // cause description |
|
227 |
// JSONObject descriptionJson = new JSONObject(); |
|
228 |
// descriptionJson.put("level", this.level); |
|
229 |
// |
|
230 |
// if (o instanceof JMethod) { |
|
231 |
// descriptionJson.put("name", "M " + getMethodDeclaration(o)); |
|
232 |
// } else if (o instanceof JField) { |
|
233 |
// descriptionJson.put("name", "F " + getFieldDeclaration(o)); |
|
234 |
// } else if (o instanceof HasName) { |
|
235 |
// descriptionJson.put("name", this.jaccMessages.getProperty(cmpResultNode.getContentCode()) + ": " + ((HasName) o).getName()); |
|
236 |
// } else { |
|
237 |
// descriptionJson.put("name", this.jaccMessages.getProperty(cmpResultNode.getContentCode())); |
|
238 |
// } |
|
239 |
// |
|
240 |
// descriptionJson.put("contentCode", cmpResultNode.getContentCode()); |
|
241 |
// descriptionJson.put("propertyName", this.jaccMessages.getProperty(cmpResultNode.getContentCode())); |
|
242 |
// descriptionJson.put("isIncompCause", cmpResultNode.isIncompatibilityCause()); |
|
243 |
// |
|
244 |
// if (o instanceof JPackage) { |
|
245 |
// descriptionJson.put("type", "package"); |
|
246 |
// descriptionJson.put("details", getPackageDetails((JPackage) o)); |
|
247 |
// } else if (o instanceof JClass) { |
|
248 |
// descriptionJson.put("type", "class"); |
|
249 |
// descriptionJson.put("details", getClassDetails((JClass) o)); |
|
250 |
// } else if (o instanceof JMethod) { |
|
251 |
// descriptionJson.put("type", "method"); |
|
252 |
// descriptionJson.put("details", getMethodDetails((JMethod) o)); |
|
253 |
// } else if (o instanceof JField) { |
|
254 |
// descriptionJson.put("type", "field"); |
|
255 |
// descriptionJson.put("details", getFieldDetails((JField) o)); |
|
256 |
// } |
|
257 |
// |
|
258 |
// // incompatibility details |
|
259 |
// if (cmpResultNode.isIncompatibilityCause()) { |
|
260 |
// if (!cmpResultNode.getResult().getInherentDiff().name().equals("DEL")) { |
|
261 |
// if (o instanceof HasName) { |
|
262 |
// descriptionJson.put("objectNameFirst", ((HasName) o).getName()); |
|
263 |
// descriptionJson.put("objectNameSecond", ((HasName) cmpResultNode.getResult().getSecondObject()).getName()); |
|
264 |
// } else { |
|
265 |
// descriptionJson.put("objectNameFirst", o.toString()); |
|
266 |
// descriptionJson.put("objectNameSecond", cmpResultNode.getResult().getSecondObject().toString()); |
|
267 |
// } |
|
268 |
// } |
|
269 |
// |
|
270 |
// String incompName = this.getIncompatibilityName(cmpResultNode, corrStrategy); |
|
271 |
// if (incompName.equals("")) { |
|
272 |
// descriptionJson.put("incompName", "Incompatible " + this.jaccMessages.getProperty(cmpResultNode.getContentCode()) + " -> " + corrStrategy); //child.getResult().getStrategy().name(); |
|
273 |
// } else { |
|
274 |
// descriptionJson.put("incompName", incompName + (cmpResultNode.getResult().getInherentDiff().name().equals("DEL") ? " is missing -> " + cmpResultNode.getResult().getStrategy().name() : "")); |
|
275 |
// } |
|
276 |
// |
|
277 |
// descriptionJson.put("strategy", cmpResultNode.getResult().getStrategy().name()); |
|
278 |
// descriptionJson.put("difference", cmpResultNode.getResult().getInherentDiff().name()); |
|
279 |
// } |
|
280 |
// |
|
281 |
// // subtree |
|
282 |
// JSONArray subtreeJson = new JSONArray(); |
|
283 |
// if (!cmpResultNode.getResult().childrenCompatible()) { |
|
284 |
// this.level++; |
|
285 |
// |
|
286 |
// List<CmpResultNode> children = cmpResultNode.getResult().getChildren(); |
|
287 |
// for (CmpResultNode child : children) { |
|
288 |
// CorrectionStrategy strategy = this.level == 1 ? cmpResultNode.getResult().getStrategy() : child.getResult().getStrategy(); |
|
289 |
// |
|
290 |
// subtreeJson.put(findIncompatibilityCause(child, strategy.name())); |
|
291 |
// } |
|
292 |
// |
|
293 |
// this.level--; |
|
294 |
// } |
|
295 |
// |
|
296 |
// |
|
297 |
// JSONObject causeJson = new JSONObject(); |
|
298 |
// causeJson.put("desc", descriptionJson); |
|
299 |
// causeJson.put("subtree", subtreeJson); |
|
300 |
// |
|
301 |
// return causeJson; |
|
302 |
// } |
|
303 |
// |
|
304 |
// private JSONObject getPackageDetails(JPackage pakkage) { |
|
305 |
// JSONObject detailsJson = new JSONObject(); |
|
306 |
// detailsJson.put("name", pakkage.getName()); |
|
307 |
// |
|
308 |
// return detailsJson; |
|
309 |
// } |
|
310 |
// |
|
311 |
// private JSONObject getClassDetails(JClass clazz) { |
|
312 |
// JSONObject detailsJson = new JSONObject(); |
|
313 |
// |
|
314 |
// detailsJson.put("name", clazz.getShortName()); |
|
315 |
// detailsJson.put("package", clazz.getPackage().getName()); |
|
316 |
// |
|
317 |
// detailsJson.put("enum", clazz.isEnum()); |
|
318 |
// detailsJson.put("interface", clazz.isInterface()); |
|
319 |
// detailsJson.put("annotation", clazz.isAnnotation()); |
|
320 |
// |
|
321 |
// detailsJson.put("abstract", clazz.getModifiers().isAbstract()); |
|
322 |
// detailsJson.put("final", clazz.getModifiers().isFinal()); |
|
323 |
// detailsJson.put("static", clazz.getModifiers().isStatic()); |
|
324 |
// |
|
325 |
// return detailsJson; |
|
326 |
// } |
|
327 |
// |
|
328 |
// private JSONObject getMethodDetails(JMethod method) { |
|
329 |
// JSONObject detailsJson = new JSONObject(); |
|
330 |
// |
|
331 |
// detailsJson.put("name", method.getName()); |
|
332 |
// detailsJson.put("returnType", method.getReturnType().getName()); |
|
333 |
// detailsJson.put("constructor", method.isConstructor()); |
|
334 |
// |
|
335 |
// List<JType> exceptionTypes = method.getExceptionTypes(); |
|
336 |
// JSONArray exceptionTypeNames = new JSONArray(); |
|
337 |
// for (JType type : exceptionTypes) { |
|
338 |
// exceptionTypeNames.put(type.getName()); |
|
339 |
// } |
|
340 |
// detailsJson.put("exceptions", exceptionTypeNames); |
|
341 |
// |
|
342 |
// List<JType> parameterTypes = method.getParameterTypes(); |
|
343 |
// JSONArray parameterTypeNames = new JSONArray(); |
|
344 |
// for (JType type : parameterTypes) { |
|
345 |
// parameterTypeNames.put(type.getName()); |
|
346 |
// } |
|
347 |
// detailsJson.put("paramTypes", parameterTypeNames); |
|
348 |
// |
|
349 |
// detailsJson.put("abstract", method.getModifiers().isAbstract()); |
|
350 |
// detailsJson.put("final", method.getModifiers().isFinal()); |
|
351 |
// detailsJson.put("static", method.getModifiers().isStatic()); |
|
352 |
// detailsJson.put("synchronized", method.getModifiers().isSynchronized()); |
|
353 |
// |
|
354 |
// return detailsJson; |
|
355 |
// } |
|
356 |
// |
|
357 |
// private JSONObject getFieldDetails(JField field) { |
|
358 |
// JSONObject detailsJson = new JSONObject(); |
|
359 |
// |
|
360 |
// detailsJson.put("name", field.getName()); |
|
361 |
// detailsJson.put("type", field.getType().getName()); |
|
362 |
// detailsJson.put("initialValue", field.getInitialValue()); |
|
363 |
// |
|
364 |
// detailsJson.put("abstract", field.getModifiers().isAbstract()); |
|
365 |
// detailsJson.put("final", field.getModifiers().isFinal()); |
|
366 |
// detailsJson.put("static", field.getModifiers().isStatic()); |
|
367 |
// |
|
368 |
// return detailsJson; |
|
369 |
// } |
|
370 |
// |
|
371 |
// private String getShortName(String longName) { |
|
372 |
// return longName.substring(longName.lastIndexOf('.') + 1); |
|
373 |
// } |
|
374 |
// |
|
375 |
// private String getMethodDeclaration(Object o) { |
|
376 |
// String methodName = ""; |
|
377 |
// methodName += getShortName(((JMethod) o).getReturnType().getName()); |
|
378 |
// methodName += " " + ((JMethod) o).getName(); |
|
379 |
// methodName += "("; |
|
380 |
// for (JType type : ((JMethod) o).getParameterTypes()) { |
|
381 |
// methodName += getShortName(type.getName()) + ", "; |
|
382 |
// } |
|
383 |
// methodName = methodName.replaceAll(", $", ""); |
|
384 |
// methodName += ")"; |
|
385 |
// return methodName; |
|
386 |
// } |
|
387 |
// |
|
388 |
// private String getFieldDeclaration(Object o) { |
|
389 |
// String fieldDeclaration = ""; |
|
390 |
// fieldDeclaration += getShortName(((JField) o).getType().getName()); |
|
391 |
// fieldDeclaration += " " + ((JField) o).getName(); |
|
392 |
// return fieldDeclaration; |
|
393 |
// } |
|
394 |
// |
|
395 |
// private String getIncompatibilityName(CmpResultNode child, String corrStrategy) { |
|
396 |
// Object o = child.getResult().getFirstObject(); |
|
397 |
// |
|
398 |
// String incompName; |
|
399 |
// switch (child.getContentCode()) { |
|
400 |
// case "cmp.child.class": |
|
401 |
// if (o instanceof HasName) { |
|
402 |
// incompName = "Class " + ((HasName) o).getName(); |
|
403 |
// } else { |
|
404 |
// incompName = "Class " + o.toString(); |
|
405 |
// } |
|
406 |
// break; |
|
407 |
// case "cmp.child.method.return.type": |
|
408 |
// incompName = this.jaccMessages.getProperty(child.getContentCode()) + " different -> " + corrStrategy; |
|
409 |
// break; |
|
410 |
// case "cmp.child.method.param.type": |
|
411 |
// if (o instanceof HasName) { |
|
412 |
// incompName = "Parameter " + getShortName(((HasName) o).getName()) + " different -> " + corrStrategy; |
|
413 |
// } else { |
|
414 |
// incompName = "Parameter " + getShortName(o.toString()) + " different -> " + corrStrategy; |
|
415 |
// } |
|
416 |
// break; |
|
417 |
// case "cmp.child.method.invocation": |
|
418 |
// incompName = "Invoke Virtual" + " -> " + child.getResult().getStrategy().name(); |
|
419 |
// break; |
|
420 |
// case "cmp.child.method": |
|
421 |
// incompName = "<span class='entity'>M</span> " + getMethodDeclaration(o); |
|
422 |
// break; |
|
423 |
// case "cmp.child.constructor": |
|
424 |
// incompName = "<span class='entity'>C</span> " + getMethodDeclaration(o); |
|
425 |
// break; |
|
426 |
// case "cmp.child.field": |
|
427 |
// incompName = "<span class='entity'>F</span> " + getFieldDeclaration(o); |
|
428 |
// break; |
|
429 |
// case "cmp.child.modifier": |
|
430 |
// incompName = "<span class='entity'>P</span> " + o.toString() + " -> " + corrStrategy; |
|
431 |
// break; |
|
432 |
// default: |
|
433 |
// incompName = ""; |
|
434 |
// break; |
|
435 |
// } |
|
436 |
// return incompName; |
|
437 |
// } |
|
438 |
// |
|
439 |
//} |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/efp/EfpComparison.java | ||
---|---|---|
1 |
//package cz.zcu.kiv.offscreen.graph.efp; |
|
2 |
// |
|
3 |
//import org.apache.log4j.Logger; |
|
4 |
// |
|
5 |
///** |
|
6 |
// * |
|
7 |
// * Holds data of EFP comparison relation. |
|
8 |
// * |
|
9 |
// * @author Jiri Loudil |
|
10 |
// * |
|
11 |
// */ |
|
12 |
//public class EfpComparison { |
|
13 |
// |
|
14 |
// /** |
|
15 |
// * Status of the EFP cmp. OK, MISSING, etc. |
|
16 |
// */ |
|
17 |
// private String comparisonStatus; |
|
18 |
// |
|
19 |
// /** |
|
20 |
// * Name of the EFP cmp. |
|
21 |
// */ |
|
22 |
// private String efpName; |
|
23 |
// |
|
24 |
// /** |
|
25 |
// * Values of the left and right side of cmp. relation. |
|
26 |
// */ |
|
27 |
// private String leftEfpValue, rightEfpValue; |
|
28 |
// |
|
29 |
// /** |
|
30 |
// * Name of the type used for the EFP cmp. relation. |
|
31 |
// */ |
|
32 |
// private String typeName; |
|
33 |
// |
|
34 |
// /** |
|
35 |
// * Logging. |
|
36 |
// */ |
|
37 |
// private Logger logger = Logger.getLogger(EfpComparison.class); |
|
38 |
// |
|
39 |
// /** |
|
40 |
// * Construct new relation. |
|
41 |
// */ |
|
42 |
// public EfpComparison() { |
|
43 |
// logger.trace("ENTRY"); |
|
44 |
// |
|
45 |
// logger.trace("EXIT"); |
|
46 |
// } |
|
47 |
// |
|
48 |
// public String getComparisonStatus() { |
|
49 |
// return comparisonStatus; |
|
50 |
// } |
|
51 |
// |
|
52 |
// public void setComparisonStatus(String comparisonStatus) { |
|
53 |
// this.comparisonStatus = comparisonStatus; |
|
54 |
// } |
|
55 |
// |
|
56 |
// public String getTypeName() { |
|
57 |
// return typeName; |
|
58 |
// } |
|
59 |
// |
|
60 |
// public void setTypeName(String typeName) { |
|
61 |
// this.typeName = typeName; |
|
62 |
// } |
|
63 |
// |
|
64 |
// public String getLeftEfpValue() { |
|
65 |
// return leftEfpValue; |
|
66 |
// } |
|
67 |
// |
|
68 |
// public void setLeftEfpValue(String leftEfpValue) { |
|
69 |
// this.leftEfpValue = leftEfpValue; |
|
70 |
// } |
|
71 |
// |
|
72 |
// public String getRightEfpValue() { |
|
73 |
// return rightEfpValue; |
|
74 |
// } |
|
75 |
// |
|
76 |
// public void setRightEfpValue(String rightEfpValue) { |
|
77 |
// this.rightEfpValue = rightEfpValue; |
|
78 |
// } |
|
79 |
// |
|
80 |
// public String getEfpName() { |
|
81 |
// return efpName; |
|
82 |
// } |
|
83 |
// |
|
84 |
// public void setEfpName(String efpName) { |
|
85 |
// this.efpName = efpName; |
|
86 |
// } |
|
87 |
// |
|
88 |
//} |
sources/src/main/java/cz/zcu/kiv/offscreen/graph/efp/EfpFeature.java | ||
---|---|---|
1 |
//package cz.zcu.kiv.offscreen.graph.efp; |
|
2 |
// |
|
3 |
//import java.util.ArrayList; |
|
4 |
// |
|
5 |
//import org.apache.log4j.Logger; |
|
6 |
// |
|
7 |
///** |
|
8 |
// * |
|
9 |
// * Holds data of a feature used in EFP relation. |
|
10 |
// * |
|
11 |
// * @author Jiri Loudil |
|
12 |
// * |
|
13 |
// */ |
|
14 |
//public class EfpFeature { |
|
15 |
// |
|
16 |
// /** |
Také k dispozici: Unified diff
Removed EFP from backend