use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class XPathTest method testCanonicalizationMulti.
@Test
public void testCanonicalizationMulti() throws Exception {
ItemPath path = new ItemPath(UserType.F_ASSIGNMENT, 1234, AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS);
assertCanonical(path, null, "\\" + COMMON + "#assignment", "\\" + COMMON + "#assignment\\" + ZERO + "#activation", "\\" + COMMON + "#assignment\\" + ZERO + "#activation\\" + ZERO + "#administrativeStatus");
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class XPathTest method xpathTest.
/**
* This is now a proper test yet.
* It does some operations with XPath. If it does not die, then the
* code some somehow consistent.
*
* It should be improved later.
*/
@Test
public void xpathTest() throws JAXBException, FileNotFoundException, IOException, ParserConfigurationException, SchemaException {
ObjectModificationType objectModification = PrismTestUtil.parseAtomicValue(new File(FILENAME_CHANGETYPE), ObjectModificationType.COMPLEX_TYPE);
for (ItemDeltaType change : objectModification.getItemDelta()) {
ItemPathType pathType = change.getPath();
System.out.println(" path=" + pathType + " (" + pathType.getClass().getName() + ") " + pathType.toString());
// NamedNodeMap attributes = path.getAttributes();
// for (int i = 0; i < attributes.getLength(); i++) {
// Node n = attributes.item(i);
// System.out.println(" A: " + n.getClass().getName() + " " + n.getNodeName() + "(" + n.getPrefix() + " : " + n.getLocalName() + ") = " + n.getNodeValue());
// }
// List<Object> any = change.getValue().getAny();
// for (Object e : any) {
// if (e instanceof Element) {
// System.out.println(" E: " + ((Element) e).getLocalName());
// }
// }
ItemPath path = pathType.getItemPath();
XPathHolder xpath = new XPathHolder(path);
AssertJUnit.assertEquals("c:extension/piracy:ship[2]/c:name", xpath.getXPathWithoutDeclarations());
System.out.println("XPATH: " + xpath);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder loader = factory.newDocumentBuilder();
Document doc = loader.newDocument();
Element xpathElement = xpath.toElement("http://elelel/", "path", doc);
Attr nsC = xpathElement.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "c");
Attr nsPiracy = xpathElement.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "piracy");
System.out.println("c: " + nsC);
System.out.println("piracy: " + nsPiracy);
// AssertJUnit.assertEquals("http://midpoint.evolveum.com/xml/ns/public/common/common-3", nsC.getValue());
// AssertJUnit.assertEquals("http://midpoint.evolveum.com/xml/ns/samples/piracy", nsPiracy.getValue());
System.out.println("XPATH Element: " + xpathElement);
XPathHolder xpathFromElement = new XPathHolder(xpathElement);
AssertJUnit.assertEquals(xpath, xpathFromElement);
// attributes = xpathElement.getAttributes();
// for (int i = 0; i < attributes.getLength(); i++) {
// Node n = attributes.item(i);
// System.out.println(" A: " + n.getNodeName() + "(" + n.getPrefix() + " : " + n.getLocalName() + ") = " + n.getNodeValue());
// }
List<XPathSegment> segments = xpath.toSegments();
System.out.println("XPATH segments: " + segments);
XPathHolder xpathFromSegments = new XPathHolder(segments);
System.out.println("XPath from segments: " + xpathFromSegments);
AssertJUnit.assertEquals("c:extension/piracy:ship[2]/c:name", xpathFromSegments.getXPathWithoutDeclarations());
}
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class XPathTest method testCanonicalizationSimpleNoNs.
@Test
public void testCanonicalizationSimpleNoNs() throws Exception {
ItemPath path = new ItemPath(UserType.F_NAME.getLocalPart());
assertCanonical(path, null, "\\#name");
assertCanonical(path, UserType.class, "\\" + COMMON + "#name");
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class XPathTest method testCanonicalizationLong.
@Test
public void testCanonicalizationLong() throws Exception {
ItemPath path = new ItemPath(ResourceType.F_CONNECTOR_CONFIGURATION, SchemaConstants.ICF_CONFIGURATION_PROPERTIES, RESOURCE_DUMMY_CONFIGURATION_USELESS_STRING_ELEMENT_NAME);
assertCanonical(path, null, "\\" + COMMON + "#connectorConfiguration", "\\" + COMMON + "#connectorConfiguration\\" + ICFS + "#configurationProperties", "\\" + COMMON + "#connectorConfiguration\\" + ICFS + "#configurationProperties\\" + ICF + "/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector#uselessString");
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class OperationalDataManager method applyMetadataModify.
public <T extends ObjectType, F extends ObjectType> void applyMetadataModify(ObjectDelta<T> objectDelta, LensElementContext<T> objectContext, Class objectTypeClass, XMLGregorianCalendar now, Task task, LensContext<F> context, OperationResult result) throws SchemaException {
String channel = LensUtil.getChannel(context, task);
PrismObjectDefinition<T> def = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(objectTypeClass);
ItemDelta.mergeAll(objectDelta.getModifications(), createModifyMetadataDeltas(context, new ItemPath(ObjectType.F_METADATA), def, now, task));
List<PrismReferenceValue> approverReferenceValues = new ArrayList<PrismReferenceValue>();
if (workflowManager != null) {
for (ObjectReferenceType approverRef : workflowManager.getApprovedBy(task, result)) {
approverReferenceValues.add(new PrismReferenceValue(approverRef.getOid()));
}
}
if (!approverReferenceValues.isEmpty()) {
ReferenceDelta refDelta = ReferenceDelta.createModificationReplace((new ItemPath(ObjectType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF)), def, approverReferenceValues);
((Collection) objectDelta.getModifications()).add(refDelta);
} else {
if (objectContext != null && objectContext.getObjectOld() != null) {
if (objectContext.getObjectOld().asObjectable().getMetadata() != null) {
List<ObjectReferenceType> existingModifyApproverRefs = objectContext.getObjectOld().asObjectable().getMetadata().getModifyApproverRef();
LOGGER.trace("Original values of MODIFY_APPROVER_REF: {}", existingModifyApproverRefs);
if (!existingModifyApproverRefs.isEmpty()) {
List<PrismReferenceValue> valuesToDelete = new ArrayList<PrismReferenceValue>();
for (ObjectReferenceType approverRef : objectContext.getObjectOld().asObjectable().getMetadata().getModifyApproverRef()) {
valuesToDelete.add(approverRef.asReferenceValue().clone());
}
ReferenceDelta refDelta = ReferenceDelta.createModificationDelete((new ItemPath(ObjectType.F_METADATA, MetadataType.F_MODIFY_APPROVER_REF)), def, valuesToDelete);
((Collection) objectDelta.getModifications()).add(refDelta);
}
}
}
}
if (FocusType.class.isAssignableFrom(objectTypeClass)) {
applyAssignmentMetadataDelta((LensContext) context, (ObjectDelta) objectDelta, now, task, result);
}
}
Aggregations