use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class TestUuid method assertLdapClient.
private void assertLdapClient(PrismObject<UserType> user, String firstName, String lastName) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
assertLinks(user, 1);
assertAssignments(user, RoleType.class, 1);
assertAssignedRole(user, ROLE_CLIENT_OID);
assertAccount(user, RESOURCE_OPENDJ_OID);
PrismReferenceValue linkRef = getLinkRef(user, RESOURCE_OPENDJ_OID);
PrismObject<ShadowType> shadow = getShadowModel(linkRef.getOid());
display("OpenDJ shadow linked to " + user, shadow);
IntegrationTestTools.assertSecondaryIdentifier(shadow, "uid=" + user.getOid() + ",ou=clients,dc=example,dc=com");
// TODO: cn, sn, givenName
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class RawTypeUtil method getParsedItem.
public static <IV extends PrismValue, ID extends ItemDefinition> Item<IV, ID> getParsedItem(ID itemDefinition, List<RawType> values, QName elementQName, PrismContainerDefinition containerDef) throws SchemaException {
Item<IV, ID> subItem = null;
List<IV> parsedValues = new ArrayList<IV>();
for (RawType rawValue : values) {
if (itemDefinition == null && containerDef != null) {
itemDefinition = (ID) ((PrismContextImpl) containerDef.getPrismContext()).getPrismUnmarshaller().locateItemDefinition(containerDef, elementQName, rawValue.getXnode());
}
IV parsed = rawValue.getParsedValue(itemDefinition, elementQName);
if (parsed != null) {
parsedValues.add(parsed);
}
}
PrismContext prismContext = null;
if (containerDef != null) {
prismContext = containerDef.getPrismContext();
}
if (prismContext == null && itemDefinition != null) {
prismContext = itemDefinition.getPrismContext();
}
if (itemDefinition == null) {
PrismProperty property = new PrismProperty(elementQName, prismContext);
property.addAll(PrismValue.cloneCollection(parsedValues));
return property;
}
if (itemDefinition instanceof PrismPropertyDefinition<?>) {
// property
PrismProperty<?> property = ((PrismPropertyDefinition<?>) itemDefinition).instantiate();
for (IV val : parsedValues) {
property.add((PrismPropertyValue) val.clone());
}
subItem = (Item<IV, ID>) property;
} else if (itemDefinition instanceof PrismContainerDefinition<?>) {
PrismContainer<?> container = ((PrismContainerDefinition<?>) itemDefinition).instantiate();
for (IV val : parsedValues) {
container.add((PrismContainerValue) val.clone());
}
subItem = (Item<IV, ID>) container;
} else if (itemDefinition instanceof PrismReferenceDefinition) {
// TODO
PrismReference reference = ((PrismReferenceDefinition) itemDefinition).instantiate();
for (IV val : parsedValues) {
PrismReferenceValue ref;
if (val instanceof PrismReferenceValue) {
ref = (PrismReferenceValue) val.clone();
} else if (val instanceof PrismContainerValue) {
// this is embedded (full) object
Containerable c = ((PrismContainerValue) val).asContainerable();
if (!(c instanceof Objectable)) {
throw new IllegalStateException("Content of " + itemDefinition + " is a Containerable but not Objectable: " + c);
}
Objectable o = (Objectable) c;
ref = new PrismReferenceValue();
ref.setObject(o.asPrismObject());
} else {
throw new IllegalStateException("Content of " + itemDefinition + " is neither PrismReferenceValue nor PrismContainerValue: " + val);
}
reference.merge(ref);
}
subItem = (Item<IV, ID>) reference;
} else {
throw new IllegalArgumentException("Unsupported definition type " + itemDefinition.getClass());
}
return subItem;
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class PrismReferenceArrayList method remove.
@Override
public boolean remove(Object o) {
T t = (T) o;
PrismReferenceValue value = getValueFrom(t);
return reference.getValues().remove(value);
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class PrismReferenceArrayList method clear.
/**
* JAXB unmarshaller is calling clear() on lists even though they were just
* created. As the references should be visible as two JAXB fields, clearing one
* of them will also clear the other. Therefore we need this hack. Calling clear()
* will only clear the values that naturally "belong" to the list.
*/
@Override
public void clear() {
List<PrismReferenceValue> values = reference.getValues();
if (values == null) {
return;
}
Iterator<PrismReferenceValue> iterator = values.iterator();
while (iterator.hasNext()) {
PrismReferenceValue value = iterator.next();
if (willClear(value)) {
iterator.remove();
}
}
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class PrismReferenceArrayList method remove.
@Override
public T remove(int i) {
testIndex(i);
PrismReferenceValue value = reference.getValues().get(i);
reference.getValues().remove(i);
return createItem(value);
}
Aggregations