-
Notifications
You must be signed in to change notification settings - Fork 148
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
Add option to include causes in the JCasC export, and read causes from it on import. #139
base: master
Are you sure you want to change the base?
Changes from all commits
3c10207
856aee4
6be3f41
4a864a1
f544c1c
2757966
b35c395
39d287f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -46,6 +46,7 @@ | |||||||
import jenkins.model.Jenkins; | ||||||||
import net.sf.json.JSONObject; | ||||||||
import org.kohsuke.stapler.DataBoundConstructor; | ||||||||
import org.kohsuke.stapler.DataBoundSetter; | ||||||||
import org.kohsuke.stapler.QueryParameter; | ||||||||
import org.kohsuke.stapler.Stapler; | ||||||||
import org.kohsuke.stapler.StaplerRequest; | ||||||||
|
@@ -86,13 +87,26 @@ public class FailureCause implements Serializable, Action, Describable<FailureCa | |||||||
* @param id the id. | ||||||||
* @param name the name of this FailureCause. | ||||||||
* @param description the description of this FailureCause. | ||||||||
* @param indications the list of indications | ||||||||
*/ | ||||||||
@DataBoundConstructor | ||||||||
public FailureCause(String id, String name, String description, List<Indication> indications) { | ||||||||
this(id, name, description, null, null, (List<String>)null, | ||||||||
indications, null); | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
* Standard constructor. | ||||||||
* | ||||||||
* @param id the id. | ||||||||
* @param name the name of this FailureCause. | ||||||||
* @param description the description of this FailureCause. | ||||||||
* @param comment the comment of this FailureCause. | ||||||||
* @param lastOccurred the time at which this FailureCause last occurred. | ||||||||
* @param categories the categories of this FailureCause. | ||||||||
* @param indications the list of indications | ||||||||
* @param modifications the modification history of this FailureCause. | ||||||||
*/ | ||||||||
@DataBoundConstructor | ||||||||
public FailureCause(String id, String name, String description, String comment, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if this is really Deprecated, the fewer parameter DataBoundConstructor and the added DataBoundSetters allow JCasC to handle optional fields, but this constructor is a lot nicer to use in code. Though if you still want it Deprecated that's fine too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The deprecation in this scenario would only be a flag to anyone coding against it that it is not the one actually used in runtime. It can still be used in tests, just annotated with something if sportbugs or checkstyle complains. |
||||||||
Date lastOccurred, String categories, List<Indication> indications, | ||||||||
List<FailureCauseModification> modifications) { | ||||||||
|
@@ -401,6 +415,7 @@ public Date getAndInitiateLastOccurred() { | |||||||
* | ||||||||
* @param lastOccurred the occurrence to set. | ||||||||
*/ | ||||||||
@DataBoundSetter | ||||||||
public void setLastOccurred(Date lastOccurred) { | ||||||||
if (lastOccurred == null) { | ||||||||
this.lastOccurred = null; | ||||||||
|
@@ -441,6 +456,26 @@ public List<String> getCategories() { | |||||||
return categories; | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
* Setter for the comment. | ||||||||
* | ||||||||
* @param comment the comment | ||||||||
*/ | ||||||||
@DataBoundSetter | ||||||||
public void setComment(String comment) { | ||||||||
this.comment = comment; | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
* Setter for the FailureCauseModifications done to this FailureCause. | ||||||||
* | ||||||||
* @param modifications the modifications | ||||||||
*/ | ||||||||
@DataBoundSetter | ||||||||
public void setModifications(List<FailureCauseModification> modifications) { | ||||||||
this.modifications = modifications; | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
* Returns the categories as a String, used for the view. | ||||||||
* | ||||||||
|
@@ -541,6 +576,7 @@ private void loadLastOccurred() { | |||||||
* | ||||||||
* @param categories the categories. | ||||||||
*/ | ||||||||
@DataBoundSetter | ||||||||
public void setCategories(List<String> categories) { | ||||||||
this.categories = categories; | ||||||||
} | ||||||||
|
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.
I am quite certain this will create duplicates for anything else than the file based knowledge base. Unless the
id
field is set. At least the javadoc should reflect that.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.
Writing a unit test for that should be relatively easy. There are a couple of integration tests using an embedded mongodb that you can take inspiration from.
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.
I've added a note about duplicates to the javadoc, there isn't much I can do about missing ids short of skipping entries that don't have one, thoughts on the preferred behavior?