Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
simonharrer committed Apr 13, 2016
1 parent 34de85c commit ac71c79
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 68 deletions.
15 changes: 15 additions & 0 deletions src/main/groovy/betsy/common/model/feature/Construct.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,19 @@ public String getID() {
public String getName() {
return name;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Construct construct = (Construct) o;
return Objects.equals(getID(), construct.getID());
}

@Override
public int hashCode() {
return Objects.hash(getID());
}
}
15 changes: 15 additions & 0 deletions src/main/groovy/betsy/common/model/feature/Feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,19 @@ public String getID() {
public String getName() {
return name;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Feature feature = (Feature) o;
return Objects.equals(getID(), feature.getID());
}

@Override
public int hashCode() {
return Objects.hash(getID());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package betsy.common.model.feature;

import betsy.common.model.HasID;
import betsy.common.model.ProcessLanguage;

public interface FeatureDimension {
Expand Down
15 changes: 15 additions & 0 deletions src/main/groovy/betsy/common/model/feature/Group.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,19 @@ public String toString() {
public String getName() {
return name;
}

@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
Group group = (Group) o;
return Objects.equals(getID(), group.getID());
}

@Override
public int hashCode() {
return Objects.hash(getID());
}
}
97 changes: 30 additions & 67 deletions src/main/groovy/betsy/tools/JsonGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
import betsy.common.engines.EngineLifecycle;
import betsy.common.model.ProcessLanguage;
import betsy.common.model.*;
import betsy.common.model.feature.Construct;
import betsy.common.model.feature.Feature;
import betsy.common.model.feature.FeatureDimension;
import betsy.common.model.feature.Group;
import com.jniwrapper.Const;
import configuration.bpel.BPELProcessRepository;
import configuration.bpmn.BPMNProcessRepository;
import org.json.JSONArray;
Expand Down Expand Up @@ -60,100 +65,59 @@ private static void addBpel(JSONArray featureTreeArray) throws IOException {
JSONObject languageObject = new JSONObject();
languageObject.put("name", ProcessLanguage.BPEL.name());
languageObject.put("id", ProcessLanguage.BPEL.getID());
JSONArray groupsArray = new JSONArray();
languageObject.put("groups", groupsArray);

BPELProcessRepository repository = BPELProcessRepository.INSTANCE;
List<EngineIndependentProcess> processes = repository.getByName("ALL");

Map<String, Map<String, List<EngineIndependentProcess>>> entries = processes.stream().
collect(Collectors.groupingBy(p -> p.getGroup().getName(),
Collectors.groupingBy(p -> p.getConstruct().getName())));
for(Map.Entry<String, Map<String, List<EngineIndependentProcess>>> entry : entries.entrySet()) {
String group = entry.getKey();

JSONObject groupObject = new JSONObject();
groupObject.put("name", group);
groupObject.put("description", "");
groupObject.put("id", String.join("__", languageObject.getString("name"), groupObject.getString("name")));
JSONArray constructsArray = new JSONArray();
groupObject.put("constructs", constructsArray);

for(Map.Entry<String, List<EngineIndependentProcess>> entry2 : entry.getValue().entrySet()) {
String construct = entry2.getKey();

JSONObject constructObject = new JSONObject();
constructObject.put("name", construct);
constructObject.put("description", "");
constructObject.put("id", String.join("__", languageObject.getString("name"), groupObject.getString("name"), constructObject.getString("name")));
JSONArray featuresArray = new JSONArray();
constructObject.put("features", featuresArray);

for(EngineIndependentProcess process : entry2.getValue()) {
String feature = process.getName();

groupObject.put("description", process.getGroup().description);

JSONObject featureObject = new JSONObject();
featureObject.put("name", feature);
featureObject.put("description", process.getDescription());
String featureID = String.join("__", languageObject.getString("name"), groupObject.getString("name"), constructObject.getString("name"), featureObject.getString("name"));
featureObject.put("id", featureID);
featureObject.put("language", process.getProcessLanguage().name());
featuresArray.put(featureObject);
}

constructsArray.put(constructObject);
}

groupsArray.put(groupObject);
}
convertProcess(languageObject, processes);
featureTreeArray.put(languageObject);
}

private static void addBpmn(JSONArray featureTreeArray) throws IOException {
JSONObject languageObject = new JSONObject();
languageObject.put("name", ProcessLanguage.BPMN.name());
languageObject.put("id", ProcessLanguage.BPMN.getID());
JSONArray groupsArray = new JSONArray();
languageObject.put("groups", groupsArray);

BPMNProcessRepository repository = new BPMNProcessRepository();
List<EngineIndependentProcess> processes = repository.getByName("ALL");
Map<String, Map<String, List<EngineIndependentProcess>>> entries = processes.stream().
collect(Collectors.groupingBy(p -> p.getGroup().getName(),
Collectors.groupingBy(p -> p.getConstruct().getName())));
for(Map.Entry<String, Map<String, List<EngineIndependentProcess>>> entry : entries.entrySet()) {
String group = entry.getKey();
convertProcess(languageObject, processes);
featureTreeArray.put(languageObject);
}

private static void convertProcess(JSONObject languageObject, List<EngineIndependentProcess> processes) {
Map<Group, Map<Construct, List<EngineIndependentProcess>>> entries = processes.stream().
collect(Collectors.groupingBy(FeatureDimension::getGroup,
Collectors.groupingBy(FeatureDimension::getConstruct)));
JSONArray groupsArray = new JSONArray();
languageObject.put("groups", groupsArray);
for(Map.Entry<Group, Map<Construct, List<EngineIndependentProcess>>> entry : entries.entrySet()) {
Group group = entry.getKey();

JSONObject groupObject = new JSONObject();
groupObject.put("name", group);
groupObject.put("description", "");
groupObject.put("id", String.join("__", languageObject.getString("name"), groupObject.getString("name")));
groupObject.put("name", group.getName());
groupObject.put("description", group.description);
groupObject.put("id", group.getID());
JSONArray constructsArray = new JSONArray();
groupObject.put("constructs", constructsArray);

for(Map.Entry<String, List<EngineIndependentProcess>> entry2 : entry.getValue().entrySet()) {
String construct = entry2.getKey();
for(Map.Entry<Construct, List<EngineIndependentProcess>> entry2 : entry.getValue().entrySet()) {
Construct construct = entry2.getKey();

JSONObject constructObject = new JSONObject();
constructObject.put("name", construct);
constructObject.put("id", String.join("__", languageObject.getString("name"), groupObject.getString("name"), constructObject.getString("name")));
constructObject.put("description", "");
constructObject.put("name", construct.getName());
constructObject.put("id", construct.getID());
constructObject.put("description", construct.description);
JSONArray featuresArray = new JSONArray();
constructObject.put("features", featuresArray);

for(EngineIndependentProcess process : entry2.getValue()) {
String feature = process.getName();
Feature feature = process.getFeature();

groupObject.put("description", process.getGroup().description);

JSONObject featureObject = new JSONObject();
featureObject.put("name", feature);
featureObject.put("description", process.getDescription());
String featureID = String.join("__", languageObject.getString("name"), groupObject.getString("name"), constructObject.getString("name"), featureObject.getString("name"));
featureObject.put("id", featureID);
featureObject.put("language", process.getProcessLanguage().name());
featureObject.put("id", feature.getID());
featureObject.put("name", feature.getName());
featureObject.put("description", feature.description);
featuresArray.put(featureObject);
}

Expand All @@ -162,7 +126,6 @@ private static void addBpmn(JSONArray featureTreeArray) throws IOException {

groupsArray.put(groupObject);
}
featureTreeArray.put(languageObject);
}

static class TestNameToLanguageFeature {
Expand Down

0 comments on commit ac71c79

Please sign in to comment.