My scenario is: One step in my jira workflow should have the ability to unschedule a task i.e. set a Fix Version to "None".
I noticed that I was not able to update fix version in a workflow post function - I don't know exactly why, but anyway I did implement a jira plugin to help me solve my problem but I know I'm going against jira structure (even java good coding practices :)). I am not sure if my implementation can cause problems, but indeed it is working in my jira instance 4.1.x.
How I've implemented a plugin to update fix version in a post function, 2 very similar ways:
public class BrandsclubPostFunctionUnschedule extends AbstractJiraFunctionProvider {
// Here I create an empty Collection to be the new value of FixVersion (empty because I need no version in Fix Version)
public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException {
MutableIssue issue = this.getIssue(transientVars);
Collection<Version> newFixVersion = new ArrayList<Version>();
issue.setFixVersions(newFixVersion);
issue.store();
}
}
public class BrandsclubPostFunctionUnschedule extends AbstractJiraFunctionProvider {
// here I clear the Collection I got from "old" Fix Version and I have to set it again to make it work.
public void execute(Map transientVars, Map args, PropertySet ps) throws WorkflowException {
MutableIssue issue = this.getIssue(transientVars);
Collection fixVersions = issue.getFixVersions();
fixVersions.clear();
issue.setFixVersions(fixVersions);
issue.store();
}
}
I presume that a real solution should use classes like: ChangeItemBean, ModifiedValue, IssueChangeHolder - taking as example the updateValue methods from CustomFieldImpl (from jira source code, project: jira, package: com.atlassian.jira.issue.fields).
My point of publishing this here is:
Does anyone know how to implement a jira plugin containing a post function to change Fix Version correctly?
If you want to do it properly take a look in the code for
./jira/src/java/com/atlassian/jira/workflow/function/issue/UpdateIssueFieldFunction.java processField()
Postfunctions that take input parameters are not documented yet it seems. Other places to go for code are other open source plugins.
Atlassian has a tutorial on doing just about exactly what you want to do, here:
I do it like in this snippet:
List<GenericValue> genericValueList = issueManager.getIssues(issues);
versionManager.moveIssuesToNewVersion(genericValueList, lastVersion, newVersion);
Related
I am trying to figure out a way to version complex Data Objects in Java. For this, I intend to store both the initial document and the diffs in a database (as well as the current object for faster access), and then be able to restore any version from the initial document by applying the diffs onto it as patches.
Thus far, I have come across Javers and java-object-diff for that, however...
Javers has no way of patching
In the java-object-diff documentation, it seems like you need both the initial as well as the target version to apply diffs, which seems kinda pointless since I want to get the target version
This seems like something that someone would have implemented a long time ago. However, thus far, I have not been able to figure out a working solution.
Can someone please help me with this?
For reference, I am currently trying to get it to work somewhat like this:
#Test
void applyDiffDeltaShouldCorrectlyApplyDeltaToCity() {
GameCharacter sylvia = GameCharacters.sylvia();
GameCharacter sylviaEdited = GameCharacters.sylviaEdited();
DiffNode characterDelta
= objectDiffer.compare(sylvia, sylviaEdited);
GameCharacter sylviaWithAppliedDelta
= applyDelta(sylvia, characterDelta);
assertEquals(sylviaEdited.getName(), sylviaWithAppliedDelta.getName());
}
public static <T> T applyDelta(T baseObject, DiffNode diff) {
//This won't work, but it would be cool if it did:
T updatedObject = baseObject + diff;
return updatedObject ;
}
I'm trying to print a call to superclass' constructor using KotlinPoet. My current (not compiling) output is:
open class NameOfASubclass : NameOfSuperclass {
}
In order to make my code compile I need to (somehow) either print
open class NameOfASubclass : NameOfSuperclass() {
}
or
open class NameOfASubclass : NameOfSuperclass {
constructor()
}
I cannot achieve it using KotlinPoet. Any ideas?
This is a bug. Here's the issue for it and here is the commit that fixes it.
There hasn't been a new release since this commit (16 of June), the last stable version is 0.3.0 (11th of June). Hopefully a new release is coming soon - there's been lots of work done since the previous one.
indeed in Kotlin Poet the problem is solved in v.0.4.0
Basically I have started updating a lot of Heroes spells to 1.7.2 and this update broke the .getHealth() and .getMaxHealth(). I am trying to fix it but I do not know how to. If anyone has some advice or samples I will be in debt. I will place some code where I use the .getHealth() method.
this is the link of the error: http://puu.sh/7BrEP.png. It is saying this method is ambigous for that type.
public void tickHero(Hero hero) {
if ( hero.getPlayer().getHealth() - damage > 1) {
addSpellTarget(hero.getPlayer(), plugin.getCharacterManager().getHero(caster));
damageEntity(hero.getPlayer(), caster, damage, DamageCause.MAGIC);
//hero.getPlayer().damage(damage, caster);
}
}
As of 1.7.2, there are two getHealth() and getMaxHealth() methods. This is becaue of the way Bukkit handled Minecraft changing the way entity health is stored in 1.6. You can read more about this here.
If you aren't using any NMS code, you should use the bukkit.jar in your build path as opposed to craftbukkit.jar. This should resolve your issue easily enough.
If you do need NMS code, you need to have both bukkit.jar AND craftbukkit.jar in your build path. Furthermore, you have to have bukkit.jar above craftbukkit.jar in the build path for it to work.
When is try to execute the following method (uses JGIT library)
private void pullRepo() throws IOException,GitAPIException, WrongRepositoryStateException, InvalidConfigurationException, DetachedHeadException, InvalidRemoteException, CanceledException, RefNotFoundException, NoHeadException{
Git git = new Git(localRepo);
git.pull().call();
}
I get the following runtime exception:
org.eclipse.jgit.api.errors.NoHeadException: Pull on repository without HEAD currently not supported
at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:161)
Does someone know how to solve this?
The localRepo I use is the same as I use for the cloneRepository method ,which works perfectly.
thanks,
bgvv1983
Think I found my mistake.
was on the wrong level in my project folder.
I was at the ../project (which works in your shell) level in stead of ../project/.git level.
I have an Java class with a static final method getAll:
public static final Vector<Category> getAll(Context context, ContentValues where) {
ArrayList<Integer> IDs = null;
if(where != null && where.containsKey(DatabaseAdapter.KEY_PRODUCT)) {
IDs = OvertureItem.getAll(context, DatabaseAdapter.TABLE_PRODUCT_CATEGORY, new String[] { DatabaseAdapter.KEY_CATEGORY }, where);
} else {
IDs = OvertureItem.getAll(context, DatabaseAdapter.TABLE_CATEGORIES, where);
}
Vector<Category> categories = new Vector<Category>();
for(Integer id: IDs) {
categories.add(Category.get(context, id));
}
return categories;
}
Now I want to hand in null as a value for the where statemant so that it will just be ignored later on in the code. Anyway in the testcase for this method I have:
Vector<Category> categories = Category.getAll(context, null);
Which then in turn gives me a NoSuchMethodError. I don't know exactly why it does that. The only thing I could imagine is that the null I hand in would not match the signature of the above method. But how can I overcome this? I already thought of overloading. But this would just end in rewriting most of the code. At least when I do it, how I think.
Any suggestions on that?
Phil
P.S. This is the stack trace I get:
java.lang.NoSuchMethodError: com.sap.catalogue.model.Category.getAll
at com.sap.overture.test.model.CategoryTest.testGetAll(CategoryTest.java:59)
at java.lang.reflect.Method.invokeNative(Native Method)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)
If the method did not exist at compile-time, then the code would not compile.
If you get NoSuchMethodError at run-time, then this suggests that the version of the Category class you are running against is different than the version of the Category class you are compiling against.
What is your setup like - is this class in the same project? Are you copying in JARs from another project?
The real answer
So I now finally figured it out and it wasn't as obvious as I expected. I started wondering, when every new test case for any new method I wrote would give me the NoSuchMethodError. So I digged a little bit deeper and then, suddenly it came to my mind: "I changed the package name of the android application". I thought this would not make any difference to the test project as long as I kept the properties right in the AndroidManifest.xml but I was wrong!
In fact when your application package is named com.foo.bar.app, the package for your tests has to be named com.foo.bar.app.test! What happened was, that with my old configuration somehow the classes that sat in the bin/ folder were used. I thought, that they should have been deleted when I cleaned the project but they weren't. This way all of the older test cases would still pass and only the new ones would give me the NoSuchMethodError. After I deleted the bin/ folder manually I got a whole bunch of errors. I then renamed the package holding the test cases and did a full clean/ rebuild on the project et voilá everything is back to normal again.
Thanks for all the tips! I really appreciate your help that just kept me digging to the bottom of the problem. Hope this here will help anybody with the same problem in the future.
Phil