use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.
the class AssignmentTablePanel method handleAssignmentDeltas.
public ContainerDelta handleAssignmentDeltas(ObjectDelta<T> userDelta, PrismContainerDefinition def, QName assignmentPath) throws SchemaException {
ContainerDelta assDelta = new ContainerDelta(new ItemPath(), assignmentPath, def, // hoping that def contains a prism
def.getPrismContext());
// context!
// PrismObject<OrgType> org =
// (PrismObject<OrgType>)getModel().getObject().getAssignmentParent();
// PrismObjectDefinition orgDef = org.getDefinition();
// PrismContainerDefinition assignmentDef =
// def.findContainerDefinition(assignmentPath);
List<AssignmentEditorDto> assignments = getAssignmentModel().getObject();
for (AssignmentEditorDto assDto : assignments) {
PrismContainerValue newValue = assDto.getNewValue(getPageBase().getPrismContext());
switch(assDto.getStatus()) {
case ADD:
newValue.applyDefinition(def, false);
assDelta.addValueToAdd(newValue.clone());
break;
case DELETE:
PrismContainerValue oldValue = assDto.getOldValue();
oldValue.applyDefinition(def);
assDelta.addValueToDelete(oldValue.clone());
break;
case MODIFY:
if (!assDto.isModified(getPageBase().getPrismContext())) {
LOGGER.trace("Assignment '{}' not modified.", new Object[] { assDto.getName() });
continue;
}
handleModifyAssignmentDelta(assDto, def, newValue, userDelta);
break;
default:
warn(getString("pageUser.message.illegalAssignmentState", assDto.getStatus()));
}
}
if (!assDelta.isEmpty()) {
assDelta = userDelta.addModification(assDelta);
}
// todo remove this block [lazyman] after model is updated - it has to
// remove resource from accountConstruction
Collection<PrismContainerValue> values = assDelta.getValues(PrismContainerValue.class);
for (PrismContainerValue value : values) {
AssignmentType ass = new AssignmentType();
ass.setupContainerValue(value);
removeResourceFromAccConstruction(ass);
}
return assDelta;
}
use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.
the class TestOpenDj method assertEntitlementGroup.
protected void assertEntitlementGroup(PrismObject<ShadowType> account, String entitlementOid) {
ShadowAssociationType associationType = IntegrationTestTools.assertAssociation(account, ASSOCIATION_GROUP_NAME, entitlementOid);
PrismContainerValue identifiersCVal = associationType.getIdentifiers().asPrismContainerValue();
PrismProperty<String> dnProp = identifiersCVal.findProperty(getSecondaryIdentifierQName());
assertNotNull("No DN identifier in group association in " + account + ", got " + identifiersCVal, dnProp);
}
use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.
the class SchemaProcessor method createContainerFieldGetterBody.
private void createContainerFieldGetterBody(JFieldVar field, ClassOutline classOutline, JMethod method) {
JBlock body = method.body();
List<JAnnotationUse> existingAnnotations = (List<JAnnotationUse>) getAnnotations(method);
for (JAnnotationUse annotation : existingAnnotations) {
if (isAnnotationTypeOf(annotation, XmlElement.class)) {
Field mfield = getField(JAnnotationUse.class, "memberValues");
mfield.setAccessible(true);
Map<String, Object> map;
try {
map = (Map<String, Object>) mfield.get(annotation);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new RuntimeException(e.getMessage(), e);
}
mfield.setAccessible(false);
map.remove("name");
annotation.param("name", normalizeFieldName(field.name()));
}
}
if (isList(field.type())) {
//JClass list = (JClass) field.type();
//JClass listType = list.getTypeParameters().get(0);
// PrismContainerValue pcv = asPrismContainerValue()
JVar pcvVar = body.decl(CLASS_MAP.get(PrismContainerValue.class), "pcv", JExpr.invoke(METHOD_AS_PRISM_CONTAINER_VALUE));
// PrismContainer container = PrismForJAXBUtil.getContainer(pcv, F_ASSIGNMENT);
JInvocation invocation = CLASS_MAP.get(PrismForJAXBUtil.class).staticInvoke(METHOD_PRISM_UTIL_GET_CONTAINER);
invocation.arg(pcvVar);
invocation.arg(JExpr.ref(fieldFPrefixUnderscoredUpperCase(field.name())));
JVar containerVar = body.decl(CLASS_MAP.get(PrismContainer.class), "container", invocation);
// anonymous class (e.g. FocusType.AnonAssignment and its methods)
JDefinedClass anonymousClass = createFieldContainerGetterListAnon(field, classOutline);
createFieldContainerCreateItemBody(field, findMethod(anonymousClass, "createItem"));
createFieldContainerGetValueFrom(field, findMethod(anonymousClass, "getValueFrom"));
// return new FocusType.AnonAssignment(container, pcv);
JInvocation newList = JExpr._new(anonymousClass);
newList.arg(containerVar);
newList.arg(pcvVar);
body._return(newList);
return;
}
JInvocation invocation = CLASS_MAP.get(PrismForJAXBUtil.class).staticInvoke(METHOD_PRISM_UTIL_GET_FIELD_SINGLE_CONTAINERABLE);
invocation.arg(JExpr.invoke(METHOD_AS_PRISM_CONTAINER_VALUE));
invocation.arg(JExpr.ref(fieldFPrefixUnderscoredUpperCase(field.name())));
invocation.arg(JExpr.dotclass((JClass) field.type()));
body._return(invocation);
}
use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.
the class CertificationCaseHelper method addCertificationCampaignCases.
public void addCertificationCampaignCases(Session session, String campaignOid, Collection<PrismContainerValue> values, int currentId, List<Long> affectedIds) throws DtoTranslationException {
for (PrismContainerValue value : values) {
AccessCertificationCaseType caseType = new AccessCertificationCaseType();
caseType.setupContainerValue(value);
if (caseType.getId() == null) {
caseType.setId((long) currentId);
currentId++;
}
// we need to generate IDs but we (currently) do not use that for setting "isTransient" flag
PrismIdentifierGenerator generator = new PrismIdentifierGenerator();
generator.generate(caseType, PrismIdentifierGenerator.Operation.MODIFY);
RAccessCertificationCase row = RAccessCertificationCase.toRepo(campaignOid, caseType, createRepositoryContext());
row.setId(RUtil.toInteger(caseType.getId()));
affectedIds.add(caseType.getId());
session.save(row);
}
}
use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.
the class TaskQuartzImpl method setExtensionContainerValue.
// use this method to avoid cloning the value
@Override
public <T extends Containerable> void setExtensionContainerValue(QName containerName, T value) throws SchemaException {
PrismContainerDefinition containerDef = getPrismContext().getSchemaRegistry().findContainerDefinitionByElementName(containerName);
if (containerDef == null) {
throw new SchemaException("Unknown container item " + containerName);
}
ArrayList<PrismContainerValue<T>> values = new ArrayList(1);
values.add(value.asPrismContainerValue());
processModificationBatched(setExtensionContainerAndPrepareDelta(containerName, containerDef, values));
}
Aggregations