Skip to content

Commit 9ce2b6c

Browse files
authored
Generated Event specific Meta classes (#41)
* Generated Event specific Meta classes * added comments in build.gradle and modified class files * modified comments in build.gradle * modified runJava task execution phase in build.gradle
1 parent 1560a7f commit 9ce2b6c

File tree

119 files changed

+5948
-1072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+5948
-1072
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.2.3
2+
- Implemented event specific meta class generation functionality
3+
14
## 0.2.2
25
- Implemented family and type functionality for creating RoutingKey in REMREM Semantics.
36

build.gradle

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,23 @@ allprojects {
3434

3535
jar {
3636
baseName = 'eiffel-remrem-semantics'
37-
version = '0.2.2'
37+
version = '0.2.3'
3838
manifest {
3939
attributes('remremVersionKey': 'semanticsVersion')
4040
attributes('semanticsVersion': version)
4141
attributes('isEndpointVersion': 'true')
4242
}
4343
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
44+
{
45+
//excluding unwanted files in jar generation these are generated by eclipse jgit api
46+
exclude "META-INF/*.SF"
47+
exclude "META-INF/*.RSA"
48+
}
4449
}
4550

4651
shadowJar {
4752
baseName = 'eiffel-remrem-semantics'
48-
version = '0.2.1'
53+
version = '0.2.3'
4954
classifier = ''
5055
}
5156

@@ -96,23 +101,37 @@ dependencies {
96101
compile 'commons-io:commons-io:2.4'
97102
compile 'org.eclipse.jgit:org.eclipse.jgit.archive:4.5.0.201609210915-r'
98103
}
99-
/**
100-
* Gradle task to execute java class based on input flag value
101-
*/
104+
105+
//compileSourceCode task to compile the source code
106+
task compileSourceCode (type: JavaCompile) {
107+
source = sourceSets.main.java.srcDirs
108+
classpath = sourceSets.main.compileClasspath
109+
destinationDir = sourceSets.main.output.classesDir
110+
}
111+
112+
//runJava task to clone schemas from github and modify the schema's for generate pojo's
102113
task runJava(type:JavaExec){
114+
doFirst{
115+
// remote repository URL to clone
103116
def remoteURL='https://github.com/Ericsson/eiffel.git'
117+
//specific branch name to clone
104118
def branch='topic-drop4'
105-
//this property is used to clone the repo, set value to "true" to clone.
106-
def isClonable = "false"
107119
main 'com.ericsson.eiffel.remrem.semantics.clone.PrepareLocalEiffelSchemas'
108120
classpath sourceSets.main.runtimeClasspath
109-
args= [remoteURL,branch,isClonable]
121+
args= [remoteURL,branch]
122+
}
110123
}
111124

112-
jar.dependsOn runJava
113-
/**
114-
* This task is used to generate Eiffel events from json schema using jsonschema2pojo plugin.
115-
*/
125+
//please set 'runJava.enabled= true' to execute the :runJava task if needed only.
126+
runJava.enabled=false;
127+
128+
//To execute the task compileSourceCode first in gradle build.
129+
compileSourceCode.execute()
130+
131+
//To execute the runJava task before jsonSchema2pojo plugin execution .
132+
generateJsonSchema2Pojo.dependsOn runJava
133+
134+
//This task is used to generate Eiffel events from json schema using jsonschema2pojo plugin.
116135
jsonSchema2Pojo {
117136
source = files("${sourceSets.main.output.resourcesDir}/schemas/input")
118137
targetDirectory = file("src/main/java")

src/main/java/com/ericsson/eiffel/remrem/semantics/EiffelEventType.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44

55

66
public enum EiffelEventType {
7-
ARTIFACT_PUBLISHED("EiffelArtifactPublishedEvent"),
8-
ACTIVITY_FINISHED("EiffelActivityFinishedEvent"),
9-
ACTIVITY_CANCELED("EiffelActivityCanceledEvent"),
10-
ARTIFACT_CREATED("EiffelArtifactCreatedEvent"),
11-
ACTIVITY_TRIGGERED("EiffelActivityTriggeredEvent"),
12-
CONFIDENCELEVEL_MODIFIED("EiffelConfidenceLevelModifiedEvent"),
13-
ACTIVITY_STARTED("EiffelActivityStartedEvent"),
14-
ANNOUNCEMENT_PUBLISHED("EiffelAnnouncementPublishedEvent"),
15-
COMPOSITION_DEFINED("EiffelCompositionDefinedEvent"),
16-
CONFIGURATION_APPLIED("EiffelConfigurationAppliedEvent"),
17-
ENVIRONMENT_DEFINED("EiffelEnvironmentDefinedEvent"),
18-
FLOWCONTEXT_DEFINED("EiffelFlowContextDefinedEvent"),
19-
SOURCECHANGE_CREATED("EiffelSourceChangeCreatedEvent"),
20-
SOURCECHANGE_SUBMITTED("EiffelSourceChangeSubmittedEvent"),
21-
TESTCASE_FINISHED("EiffelTestCaseFinishedEvent"),
22-
TESTCASE_STARTED("EiffelTestCaseStartedEvent"),
23-
TESTSUITE_FINISHED("EiffelTestSuiteFinishedEvent"),
24-
TESTSUITE_STARTED("EiffelTestSuiteStartedEvent"),
25-
ISSUE_VERIFIED("EiffelIssueVerifiedEvent"),
26-
ARTIFACT_REUSED("EiffelArtifactReusedEvent");
7+
ARTIFACT_PUBLISHED("eiffelartifactpublished"),
8+
ACTIVITY_FINISHED("eiffelactivityfinished"),
9+
ACTIVITY_CANCELED("eiffelactivitycanceled"),
10+
ARTIFACT_CREATED("eiffelartifactcreated"),
11+
ACTIVITY_TRIGGERED("eiffelactivitytriggered"),
12+
CONFIDENCELEVEL_MODIFIED("eiffelconfidencelevelmodified"),
13+
ACTIVITY_STARTED("eiffelactivitystarted"),
14+
ANNOUNCEMENT_PUBLISHED("eiffelannouncementpublished"),
15+
COMPOSITION_DEFINED("eiffelcompositiondefined"),
16+
CONFIGURATION_APPLIED("eiffelconfigurationapplied"),
17+
ENVIRONMENT_DEFINED("eiffelenvironmentdefined"),
18+
FLOWCONTEXT_DEFINED("eiffelflowcontextdefined"),
19+
SOURCECHANGE_CREATED("eiffelsourcechangecreated"),
20+
SOURCECHANGE_SUBMITTED("eiffelsourcechangesubmitted"),
21+
TESTCASE_FINISHED("eiffeltestcasefinished"),
22+
TESTCASE_STARTED("eiffeltestcasestarted"),
23+
TESTSUITE_FINISHED("eiffeltestsuitefinished"),
24+
TESTSUITE_STARTED("eiffeltestsuitestarted"),
25+
ISSUE_VERIFIED("eiffelissueverified"),
26+
ARTIFACT_REUSED("eiffelartifactreused");
2727

2828
private String id;
2929

src/main/java/com/ericsson/eiffel/remrem/semantics/RoutingKeyTypes.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44

55
public enum RoutingKeyTypes {
66

7-
EiffelActivityCanceledEvent(EiffelConstants.ACTIVITY, "canceled"),
8-
EiffelActivityFinishedEvent(EiffelConstants.ACTIVITY,"finished"),
9-
EiffelActivityStartedEvent(EiffelConstants.ACTIVITY,"started"),
10-
EiffelActivityTriggeredEvent(EiffelConstants.ACTIVITY,"triggered"),
11-
EiffelAnnouncementPublishedEvent(EiffelConstants.INFO,"announcement"),
12-
EiffelArtifactCreatedEvent(EiffelConstants.ARTIFACT,"created"),
13-
EiffelArtifactPublishedEvent(EiffelConstants.ARTIFACT,"published"),
14-
EiffelArtifactReusedEvent(EiffelConstants.ARTIFACT,"reused"),
15-
EiffelCompositionDefinedEvent(EiffelConstants.CM,"composition"),
16-
EiffelConfidenceLevelModifiedEvent(EiffelConstants.ARTIFACT,"modified"),
17-
EiffelConfigurationAppliedEvent(EiffelConstants.CONFIGURATION,"applied"),
18-
EiffelEnvironmentDefinedEvent(EiffelConstants.CM,"environment"),
19-
EiffelFlowContextDefinedEvent(EiffelConstants.FLOWCONTEXT,"defined"),
20-
EiffelIssueVerifiedEvent(EiffelConstants.TEST,"issueverified"),
21-
EiffelSourceChangeCreatedEvent(EiffelConstants.CM,"scmchange"),
22-
EiffelSourceChangeSubmittedEvent(EiffelConstants.CM,"scmproposedchange"),
23-
EiffelTestCaseFinishedEvent(EiffelConstants.TEST,"casestarted"),
24-
EiffelTestCaseStartedEvent(EiffelConstants.TEST,"casefinished"),
25-
EiffelTestSuiteFinishedEvent(EiffelConstants.TEST,"suitefinished"),
26-
EiffelTestSuiteStartedEvent(EiffelConstants.TEST,"suitestarted"),
27-
EiffelTestExecutionRecipeCollectionCreatedEvent(EiffelConstants.TEST,"execution");
7+
eiffelactivitycanceled(EiffelConstants.ACTIVITY, "canceled"),
8+
eiffelactivityfinished(EiffelConstants.ACTIVITY,"finished"),
9+
eiffelactivitystarted(EiffelConstants.ACTIVITY,"started"),
10+
eiffelactivitytriggered(EiffelConstants.ACTIVITY,"triggered"),
11+
eiffelannouncementpublished(EiffelConstants.INFO,"announcement"),
12+
eiffelartifactcreated(EiffelConstants.ARTIFACT,"created"),
13+
eiffelartifactpublished(EiffelConstants.ARTIFACT,"published"),
14+
eiffelartifactreused(EiffelConstants.ARTIFACT,"reused"),
15+
eiffelcompositiondefined(EiffelConstants.CM,"composition"),
16+
eiffelconfidencelevelmodified(EiffelConstants.ARTIFACT,"modified"),
17+
eiffelconfigurationapplied(EiffelConstants.CONFIGURATION,"applied"),
18+
eiffelenvironmentdefined(EiffelConstants.CM,"environment"),
19+
eiffelflowcontextdefined(EiffelConstants.FLOWCONTEXT,"defined"),
20+
eiffelissueverified(EiffelConstants.TEST,"issueverified"),
21+
eiffelsourcechangecreated(EiffelConstants.CM,"scmchange"),
22+
eiffelsourcechangesubmitted(EiffelConstants.CM,"scmproposedchange"),
23+
eiffeltestcasefinished(EiffelConstants.TEST,"casefinished"),
24+
eiffeltestcasestarted(EiffelConstants.TEST,"casestarted"),
25+
eiffeltestsuitefinished(EiffelConstants.TEST,"suitefinished"),
26+
eiffeltestsuitestarted(EiffelConstants.TEST,"suitestarted"),
27+
eiffeltestexecutionrecipecollectioncreated(EiffelConstants.TEST,"execution");
2828

2929
private final String family; // family
3030
private final String type; // type

src/main/java/com/ericsson/eiffel/remrem/semantics/SemanticsService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ public String generateMsg(String msgType, JsonObject bodyJson){
127127
}
128128
private static Event eventCreation(String msgType, Class<? extends Event> eventType, JsonObject msgNodes,
129129
JsonObject eventNodes) {
130+
eventNodes.add("meta", msgNodes.get("meta"));
130131
Event event = createEvent(eventNodes, eventType);
131-
event.generateMeta(msgType, msgNodes);
132-
event.setMeta(event.meta);
132+
event.setMeta(event.generateMeta(event.getMeta()));
133133
return event;
134134
}
135135

src/main/java/com/ericsson/eiffel/remrem/semantics/clone/PrepareLocalEiffelSchemas.java

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,89 @@
44
import java.io.IOException;
55
import java.util.ArrayList;
66
import java.util.List;
7-
87
import org.eclipse.jgit.api.Git;
9-
8+
import org.eclipse.jgit.api.ListBranchCommand.ListMode;
9+
import org.eclipse.jgit.lib.Ref;
1010
import com.ericsson.eiffel.remrem.semantics.schemas.EiffelConstants;
1111
import com.ericsson.eiffel.remrem.semantics.schemas.LocalRepo;
1212
import com.ericsson.eiffel.remrem.semantics.schemas.SchemaFile;
1313

1414
/**
15-
* This class is used to Clone the Eiffel Repo from github
15+
* This class is used to Clone the eiffel repo from github
1616
*
1717
* @author xdurvak
1818
*/
1919

2020
public class PrepareLocalEiffelSchemas {
2121

2222
/**
23-
* This method is used to clone Eiffel repository from github.
23+
* This method is used to clone repository from github using the URL and
24+
* branch to local destination folder.
2425
*
25-
* @param repoURL-
26-
* repository url to clone as an input parameter
27-
* @param branch-
28-
* specific branch name as an input parameter
26+
* @param repoURL
27+
* repository url to clone.
28+
* @param branch
29+
* specific branch name of the repository to clone
2930
* @param localEiffelRepoPath
30-
* - destination path to place the cloned repo as an input
31-
* parameter
31+
* destination path to clone the repo.
3232
*/
3333
private static void cloneEiffelRepo(String repoURL, String branch, File localEiffelRepoPath) {
34-
try {
35-
System.out.println("Latest Schema's Updating...");
36-
if (!localEiffelRepoPath.exists()) {
37-
Git.cloneRepository().setURI(repoURL).setBranch(branch).setDirectory(localEiffelRepoPath).call();
34+
Git localGitRepo = null;
35+
// checking for repository exists or not in the localEiffelRepoPath
36+
if (!localEiffelRepoPath.exists()) {
37+
try {
38+
// cloning github repository by using URL,branch name into local
39+
localGitRepo = Git.cloneRepository().setURI(repoURL).setBranch(branch).setDirectory(localEiffelRepoPath)
40+
.call();
41+
} catch (Exception e) {
42+
e.printStackTrace();
43+
}
44+
} else {
45+
// If required repository already exists
46+
try {
47+
localGitRepo = Git.open(localEiffelRepoPath);
48+
49+
//adding complete remote reference to the branch name
50+
String remoteBranch = EiffelConstants.REMOTE_REFERENCES.concat(branch);
51+
52+
// To fetch if any changes are available on remote repository.
53+
localGitRepo.fetch().call();
54+
55+
// checkout to input branch
56+
localGitRepo.checkout().setName(remoteBranch).call();
57+
} catch (Exception e) {
58+
e.printStackTrace();
3859
}
39-
} catch (Exception e) {
40-
e.printStackTrace();
4160
}
4261
}
4362

4463
public static void main(String[] args) throws IOException {
64+
// Read arguments from the Gradle Task.
65+
String eiffelRepoUrl = args[0];
66+
String eiffelRepoBranch = args[1];
67+
File localEiffelRepoPath = new File(
68+
System.getProperty(EiffelConstants.USER_HOME) + File.separator + EiffelConstants.EIFFEL);
4569

46-
// IsClonable checking from build.gradle
47-
if (Boolean.parseBoolean(args[2])) {
48-
49-
File localEiffelRepoPath = new File(System.getProperty(EiffelConstants.USER_HOME) + "\\" + EiffelConstants.EIFFEL);
70+
// Clone Repo from GitHub
71+
cloneEiffelRepo(eiffelRepoUrl, eiffelRepoBranch, localEiffelRepoPath);
5072

51-
// Clone Repo from GitHub
52-
cloneEiffelRepo(args[0], args[1], localEiffelRepoPath);
73+
// Read and Load JsonSchemas from Cloned Directory
74+
LocalRepo localRepo = new LocalRepo(localEiffelRepoPath);
75+
localRepo.readSchemas();
5376

54-
// Read and Load JsonSchemas from Cloned Directory
55-
LocalRepo localRepo = new LocalRepo(localEiffelRepoPath);
56-
localRepo.readSchemas();
57-
58-
ArrayList<String> jsonEventNames = localRepo.getJsonEventNames();
59-
ArrayList<File> jsonEventSchemas = localRepo.getJsonEventSchemas();
60-
61-
// Schema changes
62-
SchemaFile schemaFile = new SchemaFile(jsonEventNames.toString());
63-
// Iterate the Each jsonSchema file for Add and Modify properties
64-
if (jsonEventNames != null && jsonEventSchemas != null) {
65-
for (int i = 0; i < jsonEventNames.size(); i++) {
66-
schemaFile.modify(jsonEventSchemas.get(i), jsonEventNames.get(i));
67-
}
77+
ArrayList<String> jsonEventNames = localRepo.getJsonEventNames();
78+
ArrayList<File> jsonEventSchemas = localRepo.getJsonEventSchemas();
79+
80+
//Schema changes
81+
SchemaFile schemaFile = new SchemaFile();
82+
83+
// Iterate the Each jsonSchema file to Add and Modify the necessary
84+
// properties
85+
if (jsonEventNames != null && jsonEventSchemas != null) {
86+
for (int i = 0; i < jsonEventNames.size(); i++) {
87+
schemaFile.modify(jsonEventSchemas.get(i), jsonEventNames.get(i));
6888
}
69-
70-
} else {
71-
System.out.println("Please specify the clone property in build.gradle as an argument");
7289
}
90+
7391
}
7492
}

src/main/java/com/ericsson/eiffel/remrem/semantics/schemas/EiffelConstants.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ public final class EiffelConstants {
1717
public static String DATA = "data";
1818
public static String META = "meta";
1919
public static String EXTENDS_JAVA_CLASS = "extendsJavaClass";
20-
public static String COM_ERICSSON_EIFFEL_SEMANTICS_EVENTS_EVENT = "\"com.ericsson.eiffel.semantics.events.Event\"";
20+
public static String COM_ERICSSON_EIFFEL_SEMANTICS_EVENTS_EVENT = "com.ericsson.eiffel.semantics.events.Event";
2121
public static String JAVA_TYPE = "javaType";
2222
public static String FORMAT = "format";
2323
public static String UTC_MILLISEC = "utc-millisec";
24-
public static String COM_ERICSSON_EIFFEL_SEMANTICS_EVENTS = "\"com.ericsson.eiffel.semantics.events.";
24+
public static String COM_ERICSSON_EIFFEL_SEMANTICS_EVENTS = "com.ericsson.eiffel.semantics.events.";
2525
public static String TYPE = "type";
2626
public static String OBJECTTYPE = "object";
2727
public static String INPUT_EIFFEL_SCHEMAS = "src\\main\\resources\\schemas\\input";
@@ -30,11 +30,18 @@ public final class EiffelConstants {
3030
public static String SCHEMA_LOCATION = "\\schemas";
3131
public static String JSON_MIME_TYPE = ".json";
3232
public static String USER_HOME = "user.home";
33-
public static final String ACTIVITY = "activity";
34-
public static final String ARTIFACT = "artifact";
35-
public static final String CM = "cm";
36-
public static final String INFO = "info";
37-
public static final String CONFIGURATION = "configuration";
38-
public static final String FLOWCONTEXT = "flowcontext";
39-
public static final String TEST = "test";
33+
public static String ACTIVITY = "activity";
34+
public static String ARTIFACT = "artifact";
35+
public static String CM = "cm";
36+
public static String INFO = "info";
37+
public static String CONFIGURATION = "configuration";
38+
public static String FLOWCONTEXT = "flowcontext";
39+
public static String TEST = "test";
40+
public static String REMOTE_REFERENCES = "refs/remotes/origin/";
41+
public static String JAVA_INTERFACES = "javaInterfaces";
42+
public static String DEPENDENCY = "dependency";
43+
public static String BATCH = "batch";
44+
public static String PROPERTY = "property";
45+
public static String ANYOF = "anyOf";
46+
public static String STRING = "string";
4047
}

src/main/java/com/ericsson/eiffel/remrem/semantics/schemas/LocalRepo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.File;
44
import java.io.IOException;
55
import java.util.ArrayList;
6-
import java.util.List;
76

87
import org.apache.commons.io.FileUtils;
98

@@ -30,7 +29,7 @@ public LocalRepo(File localSchemasPath) {
3029

3130
public void readSchemas() {
3231
try {
33-
FileUtils.cleanDirectory(new File(EiffelConstants.USER_DIR + "\\" + EiffelConstants.INPUT_EIFFEL_SCHEMAS));
32+
FileUtils.cleanDirectory(new File(EiffelConstants.USER_DIR + File.separator + EiffelConstants.INPUT_EIFFEL_SCHEMAS));
3433
} catch (IOException e) {
3534
e.printStackTrace();
3635
}

0 commit comments

Comments
 (0)