@Override protected void appendDebugDumpSuffix(StringBuilder sb) { sb.append("(").append(getOid()); if (getVersion() != null) { sb.append(", v").append(getVersion()); } PrismObjectDefinition<O> def = getDefinition(); if (def != null) { sb.append(", ").append(DebugUtil.formatElementName(def.getTypeName())); } sb.append(")"); }
@NotNull private <O extends Objectable> MapXNodeImpl marshalObjectContent(@NotNull PrismObject<O> object, @NotNull PrismObjectDefinition<O> objectDefinition, SerializationContext ctx) throws SchemaException { MapXNodeImpl xmap = new MapXNodeImpl(); marshalContainerValue(xmap, object.getValue(), objectDefinition, ctx); xmap.setTypeQName(objectDefinition.getTypeName()); // object should have the definition (?) return xmap; }
/** * Returns XSD type of the object that this reference refers to. It may be * used in XPath expressions and similar filters. * * May return null if the type name is not set. * * @return the target type name */ public QName getTargetType() { if (targetType != null) { return targetType; } if (object != null && object.getDefinition() != null) { return object.getDefinition().getTypeName(); } return null; }
public RepositoryDataItem resolveRepositoryItem(Class<? extends ObjectType> aClass, ItemPath path) { QName typeName = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(aClass).getTypeName(); for (RepositoryDataItem item : getRepositoryDataItems()) { if (item.matches(typeName, path)) { return item; } } RepositoryDataItem item = new RepositoryDataItem(typeName, path); dataItems.add(item); return item; }
public static void applyDefinitionIfPresent(Collection<? extends ItemDelta> deltas, PrismObjectDefinition definition, boolean tolerateNoDefinition) throws SchemaException { for (ItemDelta itemDelta : deltas) { ItemPath path = itemDelta.getPath(); ItemDefinition itemDefinition = ((ItemDefinition) definition).findItemDefinition(path, ItemDefinition.class); if (itemDefinition != null) { itemDelta.applyDefinition(itemDefinition); } else if (!tolerateNoDefinition) { throw new SchemaException("Object type " + definition.getTypeName() + " doesn't contain definition for path " + path); } } }
private boolean personaMatches(FocusType persona, PersonaKey key) { PrismObject<? extends FocusType> personaObj = persona.asPrismObject(); QName personaType = personaObj.getDefinition().getTypeName(); if (!QNameUtil.match(personaType, key.getType())) { return false; } List<String> objectSubtypes = FocusTypeUtil.determineSubTypes(personaObj); for (String keySubtype: key.getSubtypes()) { if (!objectSubtypes.contains(keySubtype)) { return false; } } return true; }
public static <T extends Objectable> void assertObjectDefinition(PrismObjectDefinition<T> objDef, QName elementName, QName typeName, Class<T> compileTimeClass) { assertNotNull("No definition", objDef); assertEquals("Wrong elementName for "+objDef, elementName, objDef.getName()); assertEquals("Wrong typeName for "+objDef, typeName, objDef.getTypeName()); assertEquals("Wrong compileTimeClass for " + objDef, compileTimeClass, objDef.getCompileTimeClass()); }
public static QName getObjectType(ObjectType objectType, PrismContext prismContext) { if (objectType == null) { return null; } PrismObjectDefinition def = objectType.asPrismObject().getDefinition(); if (def == null) { Class<? extends Objectable> clazz = objectType.asPrismObject().getCompileTimeClass(); if (clazz == null) { return null; } def = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(clazz); if (def == null) { return ObjectType.COMPLEX_TYPE; } } return def.getTypeName(); }
@Override public PrismReferenceValue createReferenceValue(PrismObject<?> target) { PrismReferenceValue rv = new PrismReferenceValueImpl(target.getOid()); rv.setPrismContext(prismContext); rv.setObject(target); if (target.getDefinition() != null) { rv.setTargetType(target.getDefinition().getTypeName()); } return rv; }
public <O extends ObjectType> void applyObjectTemplateToDefinition(PrismObjectDefinition<O> objectDefinition, ObjectTemplateType objectTemplateType, OperationResult result) throws ObjectNotFoundException, SchemaException { if (objectTemplateType == null) { return; } for (ObjectReferenceType includeRef: objectTemplateType.getIncludeRef()) { PrismObject<ObjectTemplateType> subTemplate = cacheRepositoryService.getObject(ObjectTemplateType.class, includeRef.getOid(), null, result); applyObjectTemplateToDefinition(objectDefinition, subTemplate.asObjectable(), result); } for (ObjectTemplateItemDefinitionType templateItemDefType: objectTemplateType.getItem()) { ItemPathType ref = templateItemDefType.getRef(); if (ref == null) { throw new SchemaException("No 'ref' in item definition in "+objectTemplateType); } ItemPath itemPath = prismContext.toPath(ref); ItemDefinition itemDef = objectDefinition.findItemDefinition(itemPath); if (itemDef != null) { applyObjectTemplateItem(itemDef, templateItemDefType, "item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType); } else { OperationResult subResult = result.createMinorSubresult(SchemaTransformer.class.getName() + ".applyObjectTemplateToDefinition"); subResult.recordPartialError("No definition for item " + itemPath + " in object type " + objectDefinition.getTypeName() + " as specified in item definition in " + objectTemplateType); continue; } } }
public static <T extends ObjectType> ObjectReferenceType createObjectRef(PrismObject<T> object, boolean nameAsDescription) { if (object == null) { return null; } ObjectReferenceType ref = new ObjectReferenceType(); ref.setOid(object.getOid()); if (nameAsDescription){ ref.setDescription(object.getBusinessDisplayName()); } PrismObjectDefinition<T> definition = object.getDefinition(); if (definition != null) { ref.setType(definition.getTypeName()); } return ref; }
public static <T extends ObjectType> ObjectReferenceType createObjectRef(PrismObject<T> object, QName relation) { if (object == null) { return null; } ObjectReferenceType ref = new ObjectReferenceType(); ref.setOid(object.getOid()); PrismObjectDefinition<T> definition = object.getDefinition(); if (definition != null) { ref.setType(definition.getTypeName()); } ref.setTargetName(object.asObjectable().getName()); ref.setRelation(relation); return ref; }
private void setReferenceObject(PrismReferenceValue refVal, PrismObject<Objectable> object) throws SchemaException { refVal.setObject(object); if (object.getOid() != null) { if (refVal.getOid() == null) { refVal.setOid(object.getOid()); } else { if (!refVal.getOid().equals(object.getOid())) { throw new SchemaException("OID in reference (" + refVal.getOid() + ") does not match OID in composite object (" + object.getOid() + ")"); } } } QName objectTypeName = object.getDefinition().getTypeName(); if (refVal.getTargetType() == null) { refVal.setTargetType(objectTypeName); } else { if (!refVal.getTargetType().equals(objectTypeName)) { throw new SchemaException("Target type in reference (" + refVal.getTargetType() + ") does not match type in composite object (" + objectTypeName + ")"); } } }
public <V extends PrismValue, D extends ItemDefinition, AH extends AssignmentHolderType> Source<V,D> constructDefaultSource(ObjectDeltaObject<AH> focusOdo) throws SchemaException { if (objectTemplateMappingType != null) { return null; } PrismObject<AH> focus = focusOdo.getAnyObject(); assignmentDef = focus.getDefinition().findContainerDefinition(FocusType.F_ASSIGNMENT); PrismContainer<AssignmentType> assignment = assignmentDef.instantiate(); assignmentType = assignment.createNewValue().asContainerable(); QName relation = null; AssignmentPropertiesSpecificationType assignmentProperties = autoassignMappingType.getAssignmentProperties(); if (assignmentProperties != null) { relation = assignmentProperties.getRelation(); assignmentType.getSubtype().addAll(assignmentProperties.getSubtype()); } assignmentType.targetRef(role.getOid(), role.asPrismObject().getDefinition().getTypeName(), relation); Source<PrismContainerValue<AssignmentType>, PrismContainerDefinition<AssignmentType>> source = new Source<>(assignment, null, assignment, FocusType.F_ASSIGNMENT); return (Source<V, D>) source; }
private ObjectDelta<? extends ObjectType> createDelta(ObjectType objectType, PipelineData deltaData) throws ScriptExecutionException { if (deltaData.getData().size() != 1) { throw new ScriptExecutionException("Expected exactly one delta to apply, found " + deltaData.getData().size() + " instead."); } @SuppressWarnings({"unchecked", "raw"}) ObjectDeltaType deltaType = ((PrismPropertyValue<ObjectDeltaType>) deltaData.getData().get(0).getValue()).clone().getRealValue(); if (deltaType.getChangeType() == null) { deltaType.setChangeType(ChangeTypeType.MODIFY); } if (deltaType.getOid() == null && deltaType.getChangeType() != ChangeTypeType.ADD) { deltaType.setOid(objectType.getOid()); } if (deltaType.getObjectType() == null) { if (objectType.asPrismObject().getDefinition() == null) { throw new ScriptExecutionException("No definition for prism object " + objectType); } deltaType.setObjectType(objectType.asPrismObject().getDefinition().getTypeName()); } try { return DeltaConvertor.createObjectDelta(deltaType, prismContext); } catch (SchemaException e) { throw new ScriptExecutionException("Couldn't process delta due to schema exception", e); } } }
private <F extends FocusType> void link(LensContext<F> context, FocusType persona, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ObjectDelta<F> delta = context.getFocusContext().getObjectNew().createModifyDelta(); PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(); refValue.setOid(persona.getOid()); refValue.setTargetType(persona.asPrismObject().getDefinition().getTypeName()); delta.addModificationAddReference(FocusType.F_PERSONA_REF, refValue); repositoryService.modifyObject(delta.getObjectTypeClass(), delta.getOid(), delta.getModifications(), result); }
private <F extends FocusType> void unlink(LensContext<F> context, FocusType persona, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { ObjectDelta<F> delta = context.getFocusContext().getObjectNew().createModifyDelta(); PrismReferenceValue refValue = prismContext.itemFactory().createReferenceValue(); refValue.setOid(persona.getOid()); refValue.setTargetType(persona.asPrismObject().getDefinition().getTypeName()); delta.addModificationDeleteReference(FocusType.F_PERSONA_REF, refValue); repositoryService.modifyObject(delta.getObjectTypeClass(), delta.getOid(), delta.getModifications(), result); }
throw new SchemaException("Unknown compile time class: " + type); objectDeltaType.setObjectType(objDef.getTypeName()); objectDeltaType.setOid(objectDelta.getOid());
private void addObjectViaModelWS(ObjectType objectType, ModelExecuteOptionsType options, Holder<String> oidHolder, Holder<OperationResultType> resultHolder) throws FaultMessage { ObjectDeltaListType deltaList = new ObjectDeltaListType(); ObjectDeltaType objectDelta = new ObjectDeltaType(); objectDelta.setObjectToAdd(objectType); QName type = objectType.asPrismObject().getDefinition().getTypeName(); objectDelta.setObjectType(type); objectDelta.setChangeType(ChangeTypeType.ADD); deltaList.getDelta().add(objectDelta); ObjectDeltaOperationListType objectDeltaOperationListType = modelWeb.executeChanges(deltaList, options); ObjectDeltaOperationType objectDeltaOperationType = getOdoFromDeltaOperationList(objectDeltaOperationListType, objectDelta); resultHolder.value = objectDeltaOperationType.getExecutionResult(); oidHolder.value = ((ObjectType) objectDeltaOperationType.getObjectDelta().getObjectToAdd()).getOid(); }
public static <T extends ObjectType> ObjectReferenceType createObjectRef(PrismReferenceValue refVal, boolean nameAsDescription) { if (refVal == null) { return null; } ObjectReferenceType ref = new ObjectReferenceType(); ref.setOid(refVal.getOid()); PrismObject<T> object = refVal.getObject(); if (object != null) { if (nameAsDescription) { ref.setDescription(object.getBusinessDisplayName()); } PrismObjectDefinition<T> definition = object.getDefinition(); if (definition != null) { ref.setType(definition.getTypeName()); } ref.setTargetName(PolyString.toPolyStringType(object.getName())); } else { ref.setType(refVal.getTargetType()); ref.setTargetName(PolyString.toPolyStringType(refVal.getTargetName())); if (nameAsDescription && refVal.getTargetName() != null) { ref.setDescription(refVal.getTargetName().getOrig()); } } return ref; }