protected ItemDefinition getDefinition() { Itemable parent = getParent(); if (parent == null) { return null; } return parent.getDefinition(); }
@NotNull private <T> T extractValue(PrismPropertyValue value, Class<T> returnType) throws SchemaException { ItemDefinition definition = value.getParent().getDefinition(); //todo raw types Object object = value.getValue(); if (object instanceof Element) { object = getRealRepoValue(definition, (Element) object, prismContext); } else if (object instanceof RawType) { RawType raw = (RawType) object; object = raw.getParsedRealValue(returnType); // todo this can return null! } else { object = getAggregatedRepoObject(object); } if (returnType.isAssignableFrom(object.getClass())) { return (T) object; } throw new IllegalStateException("Can't extract value for saving from prism property value " + value + " expected return type " + returnType + ", actual type " + (object == null ? null : object.getClass())); }
@Override public void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boolean prohibitRaw, ConsistencyCheckScope scope) { if (!scope.isThorough()) { return; } ItemPath myPath = getPath(); if (StringUtils.isBlank(oid) && object == null && filter == null) { boolean mayBeEmpty = false; if (getParent() != null && getParent().getDefinition() != null) { ItemDefinition itemDefinition = getParent().getDefinition(); if (itemDefinition instanceof PrismReferenceDefinition) { PrismReferenceDefinition prismReferenceDefinition = (PrismReferenceDefinition) itemDefinition; mayBeEmpty = prismReferenceDefinition.isComposite(); } } if (!mayBeEmpty) { throw new IllegalStateException("Neither OID, object nor filter specified in reference value "+this+" ("+myPath+" in "+rootItem+")"); } } if (object != null) { try { object.checkConsistence(); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(e.getMessage()+" in reference "+myPath+" in "+rootItem, e); } catch (IllegalStateException e) { throw new IllegalStateException(e.getMessage()+" in reference "+myPath+" in "+rootItem, e); } } }
ItemDefinition def = null; Itemable parent = getParent(); if (parent != null && parent.getDefinition() != null) { def = getParent().getDefinition();
public <O extends ObjectType> PrismObject<O> resolve(PrismReferenceValue refVal, String string, GetOperationOptions options, Task task, OperationResult result) throws ObjectNotFoundException { String oid = refVal.getOid(); Class<?> typeClass = ObjectType.class; QName typeQName = refVal.getTargetType(); if (typeQName == null && refVal.getParent() != null && refVal.getParent().getDefinition() != null) { PrismReferenceDefinition refDef = (PrismReferenceDefinition) refVal.getParent().getDefinition(); typeQName = refDef.getTargetTypeName(); } if (typeQName != null) { typeClass = prismContext.getSchemaRegistry().determineCompileTimeClass(typeQName); } return (PrismObject<O>) (getObjectSimple((Class<O>)typeClass, oid, options, task, result)).asPrismObject(); }
public Referencable asReferencable() { if (referencable != null) { return referencable; } Itemable parent = getParent(); if (parent != null) { QName xsdType = parent.getDefinition().getTypeName(); Class clazz = getPrismContext().getSchemaRegistry().getCompileTimeClass(xsdType); if (clazz != null) { try { referencable = (Referencable) clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new SystemException("Couldn't create jaxb object instance of '" + clazz + "': " + e.getMessage(), e); } } referencable.setupReferenceValue(this); } // A hack, just to avoid crashes. TODO think about this! return new DefaultReferencableImpl(this); }
/** * Takes the definition from the definitionSource parameter and uses it to parse raw elements in origValue. * It returns a new parsed value without touching the original value. */ private PrismPropertyValue<T> parseRawElementToNewValue( PrismPropertyValue<T> origValue, PrismPropertyValue<T> definitionSource) throws SchemaException { if (definitionSource.getParent() != null && definitionSource.getParent().getDefinition() != null) { T parsedRealValue = (T) parseRawElementToNewRealValue(origValue, (PrismPropertyDefinition) definitionSource.getParent().getDefinition()); PrismPropertyValue<T> newPVal = new PrismPropertyValueImpl<>(parsedRealValue); return newPVal; } else if (definitionSource.getRealClass() != null && definitionSource.getPrismContext() != null) { T parsedRealValue = parseRawElementToNewRealValue(origValue, (Class<T>) definitionSource.getRealClass(), definitionSource.getPrismContext()); PrismPropertyValue<T> newPVal = new PrismPropertyValueImpl<>(parsedRealValue); return newPVal; } else { throw new IllegalArgumentException("Attempt to use property " + origValue.getParent() + " values in a raw parsing state (raw elements) with parsed value that has no definition nor class with prism context"); } }
info.itemDefinition = itemDefinition = value.getParent().getDefinition(); if (info.itemDefinition == null) { info.itemDefinition = schemaRegistry.findItemDefinitionByElementName(value.getParent().getElementName());
return; ItemDefinition itemDef = item.getDefinition(); if (itemDef == null) { return;
return; ItemDefinition itemDef = item.getDefinition(); if (itemDef == null) { return;
public RAnyValue convertToRValue(PrismValue value, boolean assignment, RObjectExtensionType ownerType) throws SchemaException { RAnyValue rValue; ItemDefinition definition = value.getParent().getDefinition(); if (!isIndexed(definition, value.getParent().getElementName(), areDynamicsOfThisKindIndexed(ownerType), prismContext)) { return null; } if (value instanceof PrismPropertyValue) { PrismPropertyValue propertyValue = (PrismPropertyValue) value; rValue = extractAndCreateValue(definition, propertyValue, assignment); } else if (value instanceof PrismReferenceValue) { if (assignment) { PrismReferenceValue referenceValue = (PrismReferenceValue) value; rValue = RAExtReference.createReference(referenceValue); } else { PrismReferenceValue referenceValue = (PrismReferenceValue) value; rValue = ROExtReference.createReference(referenceValue); } } else { // shouldn't get here because if isIndexed test above throw new AssertionError("Wrong value type: " + value); } rValue.setItemId(extItemDictionary.createOrFindItemDefinition(definition).getId()); return rValue; }
if (value instanceof PrismPropertyValue) { PrismPropertyValue<Object> pval = (PrismPropertyValue)value; if (pval.isRaw() && parent.getDefinition() == null) { XNodeImpl rawElement = (XNodeImpl) pval.getRawElement(); if (rawElement instanceof MapXNodeImpl) {
PrismReferenceDefinition definition = (PrismReferenceDefinition) refVal.getParent().getDefinition(); if (definition != null) { typeQName = definition.getTargetTypeName();