Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
This exception coming on wc11.1 only.
A persistence error occurred. System message follows:
Nested exception is: wt.associationRules.AssociationValidationException: Removing an association between "Change Notice - 00001" and "Change Task - 00001" violates the required role constraint of "Association Rule - PTC000007". The association is required for "Change Notice - 00001".
Please check sample code as below :
// Get change Task here..
QueryResult changeActivityList = ChangeHelper2.service.getChangeActivities(changenotice);
while (changeActivityList.hasMoreElements()) {
//get ChangeTask obj
ChangeActivity2 changeActivity = (ChangeActivity2) changeActivityList.nextElement();
//get Affected obj
QueryResult qr2 = PersistenceHelper.manager.navigate(changeActivity,AffectedActivityData.ALL_ROLES, AffectedActivityData.class, false);
while (qr2.hasMoreElements()) {
AffectedActivityData affecteddata = (AffectedActivityData) qr2.nextElement();
ChangeHelper2.service.deleteAffectedActivityData(affecteddata);
System.out.println("deleted Affected Activity from Change task..!");
}
// get Resulting Obj.
QueryResult qr3 = PersistenceHelper.manager.navigate(changeActivity,ChangeRecord2.ALL_ROLES, ChangeRecord2.class, false);
while (qr3.hasMoreElements()) {
ChangeRecord2 changerecord = (ChangeRecord2) qr3.nextElement();
ChangeHelper2.service.deleteChangeRecord(changerecord);
System.out.println("deleted Resulting Data from Change task..!");
}
System.out.println("Change task name : "+changeActivity.getName());
System.out.println("Deleted change task started..!");
// delete change task.
ChangeHelper2.service.deleteChangeActivity(changeActivity);
System.out.println("Deleted change task success..!");
}
Solved! Go to Solution.
HI Windchiller,
Please use this API :
here an example :
ObjectIdentifier oid= ObjectIdentifier.newObjectIdentifier("wt.change2.WTChangeActivity2:396443");
wt.change2.WTChangeActivity2 ct = (wt.change2.WTChangeActivity2) PersistenceHelper.manager.refresh(oid);
IncludedIn2 changeLnk = null;
WTSet myCT= new WTHashSet();
myCT.add(ct);
WTCollection list = new WTArrayList(PersistenceHelper.navigate(ct, IncludedIn2.ROLE_AOBJECT_ROLE, IncludedIn2.class, false));
for (Object o : list) {
changeLnk = (IncludedIn2) ((ObjectReference) o).getObject();
System.out.println(changeLnk.getChangeOrder2());
}
ChangeHelper2.service.deleteIncludeIn2AndChangeTask(myCT, changeLnk.getChangeOrder2(),false);
Good luck
HI Windchiller,
Please use this API :
here an example :
ObjectIdentifier oid= ObjectIdentifier.newObjectIdentifier("wt.change2.WTChangeActivity2:396443");
wt.change2.WTChangeActivity2 ct = (wt.change2.WTChangeActivity2) PersistenceHelper.manager.refresh(oid);
IncludedIn2 changeLnk = null;
WTSet myCT= new WTHashSet();
myCT.add(ct);
WTCollection list = new WTArrayList(PersistenceHelper.navigate(ct, IncludedIn2.ROLE_AOBJECT_ROLE, IncludedIn2.class, false));
for (Object o : list) {
changeLnk = (IncludedIn2) ((ObjectReference) o).getObject();
System.out.println(changeLnk.getChangeOrder2());
}
ChangeHelper2.service.deleteIncludeIn2AndChangeTask(myCT, changeLnk.getChangeOrder2(),false);
Good luck