@Override public PrismContext getPrismContext() { if (prismContext != null) { return prismContext; } else if (parent != null) { return parent.getPrismContext(); } else { return null; } }
private Object asElement(PrismValue itemValue) { PrismContext prismContext = containerValue.getPrismContext(); if (prismContext == null) { throw new IllegalStateException("prismContext is null in " + containerValue); } try { return prismContext.getJaxbDomHack().toAny(itemValue); } catch (SchemaException e) { throw new SystemException("Unexpected schema problem: "+e.getMessage(),e); } }
public static WfContextType getWorkflowContext(WorkItemType workItem) { PrismContainerValue<?> parent = PrismValueUtil.getParentContainerValue(workItem.asPrismContainerValue()); if (parent == null) { LOGGER.error("No workflow context for workItem {}", workItem); // this is only a workaround, FIXME MID-4030 return new WfContextType(workItem.asPrismContainerValue().getPrismContext()); } Containerable parentReal = parent.asContainerable(); if (!(parentReal instanceof WfContextType)) { throw new IllegalStateException("WorkItem's parent is not a WfContextType; it is " + parentReal); } return (WfContextType) parentReal; }
@Override public boolean add(@NotNull PrismContainerValue newValue, boolean checkUniqueness) throws SchemaException { checkMutability(); // when a context-less item is added to a contextful container, it is automatically adopted if (newValue.getPrismContext() == null && this.prismContext != null) { prismContext.adopt(newValue); } if (newValue.getId() != null) { for (PrismContainerValue existingValue : getValues()) { if (existingValue.getId() != null && existingValue.getId().equals(newValue.getId())) { throw new IllegalStateException("Attempt to add a container value with an id that already exists: " + newValue.getId()); } } } return super.add(newValue, checkUniqueness); }
public static <T extends Containerable> boolean setFieldContainerValue(PrismContainerValue<?> parent, ItemName fieldName, PrismContainerValue<T> fieldContainerValue) { Validate.notNull(parent, "Prism container value must not be null."); Validate.notNull(fieldName, "QName must not be null."); try { PrismContainer<T> fieldContainer = null; if (fieldContainerValue == null) { parent.removeContainer(fieldName); } else { if (fieldContainerValue.getParent() != null && fieldContainerValue.getParent() != parent) { // This value is already part of another prism. We need to clone it to add it here. fieldContainerValue = fieldContainerValue.clone(); } fieldContainer = new PrismContainerImpl<>(fieldName, parent.getPrismContext()); fieldContainer.add(fieldContainerValue); parent.addReplaceExisting(fieldContainer); } } catch (SchemaException e) { // This should not happen. Code generator and compiler should take care of that. throw new IllegalStateException("Internal schema error: "+e.getMessage(),e); } return true; }
assertNotNull(b1.asPrismContainerValue().getPrismContext()); assertNotNull(b2.asPrismContainerValue().getPrismContext()); assertFalse(b1.equals(b2));