-
Notifications
You must be signed in to change notification settings - Fork 6
PART 2: Generate events using jsonschema2pojo and mustache template #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
8b200ae
Changes to generate class file using template
f40e395
update CDEventsGenerator file
12fa8c2
update CDEventsGenerator file
a2673d1
Update phase for CDEventsGenerator main class
1aa585b
adding missing file to repo
a57c616
Update src/main/java/dev/cdevents/CDEventsGenerator.java
rjalander a9e7c90
Update src/main/java/dev/cdevents/CDEventsGenerator.java
rjalander 2a66889
update with review comments and some linter issues
487705a
fix linter issues
30f3e7d
updating linter.yml
678e197
fix linter issues with MagicNumber
a8c7831
fix linter issues with MagicNumber
90f2e2a
lint exclude list in array path
20cd637
update FILTER_REGEX_EXCLUDE pattern
759d00c
update MaginNumners with constants
a5bb503
ignoreFieldDeclaration for MagicNumber check-style
e865d59
cleanup existing/manual events to keep only gererated events
3369ae9
Generate models and events from spec/schema repo
9865d62
Changes to generate class file using template
886070a
update CDEventsGenerator file
3653b32
update CDEventsGenerator file
7366ba2
Update phase for CDEventsGenerator main class
fcb0514
adding missing file to repo
8dc440a
Update src/main/java/dev/cdevents/CDEventsGenerator.java
rjalander 8bf6783
Update src/main/java/dev/cdevents/CDEventsGenerator.java
rjalander 8715628
update with review comments and some linter issues
8e837e6
fix linter issues
fb70e74
updating linter.yml
a594c13
fix linter issues with MagicNumber
04151e7
fix linter issues with MagicNumber
4e1c5ed
lint exclude list in array path
68f666b
update FILTER_REGEX_EXCLUDE pattern
30c6654
update MaginNumners with constants
05e0dd3
ignoreFieldDeclaration for MagicNumber check-style
d78dfeb
cleanup existing/manual events to keep only gererated events
a2e9beb
Refacoring the code to use maven submodules for generator and sdk
81a7864
fix minor lint issue
ea383aa
updating release files as per comment
77f84e4
Changes to generate class file using template
52992b5
Merge branch 'gen_sdk_v0_1_2' of github.com:Nordix/sdk-java into gen_…
9c10633
removing plugin definition from sdk/pom
8b4ec23
removing test dependencies
6571579
Merge branch 'main' into gen_sdk_v0_1_2
rjalander 4080307
Update parent pom artifactId
7aa2e7e
Update sdk and generator pom artifact version
c12ab5a
merge from gen_sdk_v0_1_2 branch for the latest changes
65de572
adding test file to sdk
29feacf
removing old event files
fca78fb
merge from master branch with events generator changes
7eda387
fix linter issue
a9631b5
adding submodule in actions to checkout
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "spec"] | ||
path = spec | ||
url = git@github.com:cdevents/spec.git |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,7 +196,6 @@ | |
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<profiles> | ||
<profile> | ||
<id>publication</id> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
sdk/src/main/java/dev/cdevents/events/BranchCreatedCDEvent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
// Code generated by dev.cdevents.generator.CDEventsGenerator. DO NOT EDIT. | ||
|
||
/* | ||
Copyright 2023 The CDEvents Authors | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package dev.cdevents.events; | ||
|
||
|
||
import dev.cdevents.constants.CDEventConstants; | ||
import dev.cdevents.exception.CDEventsException; | ||
import dev.cdevents.models.CDEvent; | ||
import dev.cdevents.models.branch.created.*; | ||
|
||
import java.net.URI; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
|
||
public class BranchCreatedCDEvent extends Branchcreated implements CDEvent { | ||
|
||
|
||
/** | ||
* Constructor to init CDEvent and set the Subject for {@link BranchCreatedCDEvent}. | ||
*/ | ||
|
||
public BranchCreatedCDEvent() { | ||
initCDEvent(); | ||
} | ||
|
||
|
||
/** | ||
* Initialize the CDEvent with the context values. | ||
*/ | ||
|
||
@Override | ||
public void initCDEvent() { | ||
setContext(new Context()); | ||
setSubject(new Subject()); | ||
setCustomData(new Object()); | ||
setCustomDataContentType("application/json"); | ||
Context context = getContext(); | ||
context.setId(UUID.randomUUID().toString()); | ||
context.setTimestamp(new Date()); | ||
context.setVersion(CDEventConstants.CDEVENTS_SPEC_VERSION); | ||
getSubject().setContent(new Content()); | ||
getSubject().getContent().setRepository(new Repository()); | ||
getSubject().setType(CDEventConstants.SubjectType.BRANCH.getSubjectType()); | ||
} | ||
|
||
/** | ||
* @return the event source | ||
*/ | ||
|
||
@Override | ||
public String eventSource() { | ||
return getContext().getSource(); | ||
} | ||
|
||
|
||
/** | ||
* @return the current CDEvent type | ||
*/ | ||
|
||
@Override | ||
public String currentCDEventType() { | ||
return getContext().getType().value(); | ||
} | ||
|
||
|
||
/** | ||
* @return the branchcreated.json schema URL | ||
*/ | ||
|
||
@Override | ||
public String schemaURL() { | ||
return "https://cdevents.dev/0.1.2/schema/branch-created-event"; | ||
} | ||
|
||
|
||
/** | ||
* @return the branchcreated.json schema Json | ||
*/ | ||
|
||
@Override | ||
public String eventSchema() { | ||
try { | ||
return Files.readString(Paths.get(CDEventConstants.SCHEMA_FOLDER + "/branchcreated.json")); | ||
} catch (IOException e) { | ||
throw new CDEventsException("Exception while reading Event JsonSchema file ", e); | ||
} | ||
} | ||
|
||
|
||
/** | ||
* @param source | ||
* Sets the {@link Context} source value | ||
*/ | ||
|
||
public void setSource(URI source) { | ||
getContext().setSource(source.toString()); | ||
} | ||
|
||
|
||
/** | ||
* @param subjectId | ||
* sets the subject Id | ||
*/ | ||
|
||
public void setSubjectId(String subjectId) { | ||
getSubject().setId(subjectId); | ||
} | ||
|
||
|
||
/** | ||
* @param subjectSource | ||
* sets the subject source | ||
*/ | ||
|
||
public void setSubjectSource(URI subjectSource) { | ||
getSubject().setSource(subjectSource.toString()); | ||
} | ||
|
||
|
||
|
||
/** | ||
* @param id | ||
*/ | ||
public void setSubjectRepositoryId(String id) { | ||
getSubject().getContent().getRepository().setId(id); | ||
} | ||
/** | ||
* @param source | ||
*/ | ||
public void setSubjectRepositorySource(String source) { | ||
getSubject().getContent().getRepository().setSource(source); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For automation purposes, it would be nice if the tool accumulated the various errors and failed at the end, rather than only logging errors.