use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class CoreUtils method getLoadID.
private static <T> String getLoadID(T obj) {
if (obj instanceof Identified) {
Identified l = (Identified) obj;
String name = l.getDisplayName();
String id = obj.getClass().getSimpleName() + ": " + name;
if (!l.getKeyName().equals(name)) {
id = id + " [" + l.getKeyName() + "]";
}
return id;
} else if (obj instanceof QualifiedObject) {
QualifiedObject<?> qo = (QualifiedObject<?>) obj;
return getLoadID(qo.getRawObject());
} else if (obj instanceof CDOMReference) {
CDOMReference<?> ref = (CDOMReference<?>) obj;
return ref.getReferenceClass().getSimpleName() + " Primitive: " + ref.getLSTformat(false);
} else {
return obj.getClass().getSimpleName() + ": " + obj.toString();
}
}
use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class AbstractListContext method commit.
void commit() {
ListCommitStrategy commit = getCommitStrategy();
for (CDOMReference<? extends CDOMList<?>> list : edits.positiveMasterMap.getKeySet()) {
//Note: Intentional Generics Violation due to Sun Compiler
commitDirect((CDOMReference) list);
}
for (CDOMReference<? extends CDOMList<?>> list : edits.negativeMasterMap.getKeySet()) {
//Note: Intentional Generics Violation due to Sun Compiler
removeDirect((CDOMReference) list);
}
for (URI uri : edits.globalClearSet.getKeySet()) {
for (CDOMObject owner : edits.globalClearSet.getSecondaryKeySet(uri)) {
for (String tokenName : edits.globalClearSet.getTertiaryKeySet(uri, owner)) {
for (CDOMReference<? extends CDOMList<?>> list : edits.globalClearSet.getListFor(uri, owner, tokenName)) {
commit.removeAllFromList(tokenName, owner, list);
}
}
}
}
for (URI uri : edits.negativeMap.getKeySet()) {
for (CDOMObject owner : edits.negativeMap.getSecondaryKeySet(uri)) {
CDOMObject neg = edits.negativeMap.get(uri, owner);
Collection<CDOMReference<? extends CDOMList<?>>> modifiedLists = neg.getModifiedLists();
for (CDOMReference<? extends CDOMList<?>> list : modifiedLists) {
//Note: Intentional Generics Violation due to Sun Compiler
remove(owner, neg, (CDOMReference) list);
}
}
}
for (URI uri : edits.positiveMap.getKeySet()) {
for (CDOMObject owner : edits.positiveMap.getSecondaryKeySet(uri)) {
CDOMObject neg = edits.positiveMap.get(uri, owner);
Collection<CDOMReference<? extends CDOMList<?>>> modifiedLists = neg.getModifiedLists();
for (CDOMReference<? extends CDOMList<?>> list : modifiedLists) {
//Note: Intentional Generics Violation due to Sun Compiler
add(owner, neg, (CDOMReference) list);
}
}
}
for (String token : edits.masterAllClear.getKeySet()) {
for (OwnerURI ou : edits.masterAllClear.getListFor(token)) {
commit.clearAllMasterLists(token, ou.owner);
}
}
rollback();
}
use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class ListChanges method getAdded.
@Override
public Collection<CDOMReference<T>> getAdded() {
TreeSet<CDOMReference<T>> set = new TreeSet<>(ReferenceUtilities.REFERENCE_SORTER);
Collection<CDOMReference<T>> listMods = positive.getListMods(list);
if (listMods != null) {
for (CDOMReference<T> ref : listMods) {
for (AssociatedPrereqObject assoc : positive.getListAssociations(list, ref)) {
if (tokenName.equals(assoc.getAssociation(AssociationKey.TOKEN))) {
set.add(ref);
}
}
}
}
return set;
}
use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class ListChanges method getRemoved.
@Override
public Collection<CDOMReference<T>> getRemoved() {
TreeSet<CDOMReference<T>> set = new TreeSet<>(ReferenceUtilities.REFERENCE_SORTER);
if (negative == null) {
return set;
}
Collection<CDOMReference<T>> listMods = negative.getListMods(list);
if (listMods != null) {
for (CDOMReference<T> ref : listMods) {
for (AssociatedPrereqObject assoc : negative.getListAssociations(list, ref)) {
if (tokenName.equals(assoc.getAssociation(AssociationKey.TOKEN))) {
set.add(ref);
}
}
}
}
return set;
}
use of pcgen.cdom.base.CDOMReference in project pcgen by PCGen.
the class AbstractListContext method remove.
private <BT extends CDOMObject, L extends CDOMList<BT>> void remove(CDOMObject owner, CDOMObject neg, CDOMReference<L> list) {
ListCommitStrategy commit = getCommitStrategy();
Collection<CDOMReference<BT>> mods = neg.getListMods(list);
for (CDOMReference<BT> ref : mods) {
for (AssociatedPrereqObject assoc : neg.getListAssociations(list, ref)) {
String token = assoc.getAssociation(AssociationKey.TOKEN);
AssociatedPrereqObject edge = commit.removeFromList(token, owner, list, ref);
Collection<AssociationKey<?>> associationKeys = assoc.getAssociationKeys();
for (AssociationKey<?> ak : associationKeys) {
setAssoc(assoc, edge, ak);
}
edge.addAllPrerequisites(assoc.getPrerequisiteList());
}
}
}
Aggregations