Search in sources :

Example 11 with ObjectFactory

use of com.evolveum.prism.xml.ns._public.query_3.ObjectFactory in project ddf by codice.

the class AbstractCswSource method createSubscriptionGetRecordsRequest.

private GetRecordsType createSubscriptionGetRecordsRequest() {
    GetRecordsType getRecordsType = new GetRecordsType();
    getRecordsType.setVersion(cswVersion);
    getRecordsType.setService(CswConstants.CSW);
    getRecordsType.setResultType(ResultType.RESULTS);
    getRecordsType.setStartPosition(BigInteger.ONE);
    getRecordsType.setMaxRecords(BigInteger.TEN);
    getRecordsType.setOutputFormat(MediaType.APPLICATION_XML);
    getRecordsType.setOutputSchema("urn:catalog:metacard");
    getRecordsType.getResponseHandler().add(SystemBaseUrl.constructUrl("csw/subscription/event", true));
    QueryType queryType = new QueryType();
    queryType.setElementSetName(createElementSetName(ElementSetType.FULL));
    ObjectFactory objectFactory = new ObjectFactory();
    getRecordsType.setAbstractQuery(objectFactory.createQuery(queryType));
    return getRecordsType;
}
Also used : ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType)

Example 12 with ObjectFactory

use of com.evolveum.prism.xml.ns._public.query_3.ObjectFactory in project ddf by codice.

the class CswSubscriptionEndpointTest method testCreateOrUpdateSubscriptionPersitanceFalse.

@Test
public void testCreateOrUpdateSubscriptionPersitanceFalse() throws Exception {
    ObjectFactory objectFactory = new ObjectFactory();
    GetRecordsType getRecordsType = createDefaultGetRecordsRequest().get202RecordsType();
    QueryType queryType = new QueryType();
    getRecordsType.setAbstractQuery(objectFactory.createQuery(queryType));
    cswSubscriptionEndpoint.createOrUpdateSubscription(getRecordsType, subscriptionId, false);
    verify(mockContext).registerService(eq(Subscription.class.getName()), any(Subscription.class), any(Dictionary.class));
}
Also used : Dictionary(java.util.Dictionary) ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) Subscription(ddf.catalog.event.Subscription) CswSubscription(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.event.CswSubscription) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) Test(org.junit.Test)

Example 13 with ObjectFactory

use of com.evolveum.prism.xml.ns._public.query_3.ObjectFactory in project ddf by codice.

the class CswQueryFactoryTest method setUp.

@org.junit.Before
public void setUp() throws URISyntaxException, SourceUnavailableException, UnsupportedQueryException, FederationException, ParseException, IngestException {
    filterBuilder = new GeotoolsFilterBuilder();
    FilterAdapter filterAdapter = new GeotoolsFilterAdapterImpl();
    metacardTypeList = new ArrayList<>();
    queryFactory = new CswQueryFactory(filterBuilder, filterAdapter, getCswMetacardType(), metacardTypeList);
    AttributeRegistry mockAttributeRegistry = mock(AttributeRegistry.class);
    when(mockAttributeRegistry.lookup(TITLE_TEST_ATTRIBUTE)).thenReturn(Optional.of(mock(AttributeDescriptor.class)));
    queryFactory.setAttributeRegistry(mockAttributeRegistry);
    polygon = new WKTReader().read(POLYGON_STR);
    gmlObjectFactory = new net.opengis.gml.v_3_1_1.ObjectFactory();
    filterObjectFactory = new ObjectFactory();
}
Also used : ObjectFactory(net.opengis.filter.v_1_1_0.ObjectFactory) AttributeRegistry(ddf.catalog.data.AttributeRegistry) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) FilterAdapter(ddf.catalog.filter.FilterAdapter) GeotoolsFilterAdapterImpl(ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl) WKTReader(com.vividsolutions.jts.io.WKTReader)

Example 14 with ObjectFactory

use of com.evolveum.prism.xml.ns._public.query_3.ObjectFactory in project midpoint by Evolveum.

the class TestUserChangeApprovalLegacy method modifyAssignmentConstruction.

protected void modifyAssignmentConstruction(LensContext<UserType> context, UserType jack, String attributeName, String value, boolean add) throws SchemaException {
    assertEquals("jack's assignments", 1, jack.getAssignment().size());
    PrismPropertyDefinition<ResourceAttributeDefinitionType> attributeDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class).findPropertyDefinition(new ItemPath(UserType.F_ASSIGNMENT, AssignmentType.F_CONSTRUCTION, ConstructionType.F_ATTRIBUTE));
    assertNotNull("no attributeDef", attributeDef);
    Long assignmentId = jack.getAssignment().get(0).getId();
    PropertyDelta<ResourceAttributeDefinitionType> attributeDelta = new PropertyDelta<ResourceAttributeDefinitionType>(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(assignmentId), new NameItemPathSegment(AssignmentType.F_CONSTRUCTION), new NameItemPathSegment(ConstructionType.F_ATTRIBUTE)), attributeDef, prismContext);
    ResourceAttributeDefinitionType attributeDefinitionType = new ResourceAttributeDefinitionType();
    attributeDefinitionType.setRef(new ItemPathType(new ItemPath(new QName(RESOURCE_DUMMY_NAMESPACE, attributeName))));
    MappingType outbound = new MappingType();
    // to see changes on the resource
    outbound.setStrength(MappingStrengthType.STRONG);
    ExpressionType expression = new ExpressionType();
    expression.getExpressionEvaluator().add(new ObjectFactory().createValue(value));
    outbound.setExpression(expression);
    attributeDefinitionType.setOutbound(outbound);
    if (add) {
        attributeDelta.addValueToAdd(new PrismPropertyValue<>(attributeDefinitionType));
    } else {
        attributeDelta.addValueToDelete(new PrismPropertyValue<>(attributeDefinitionType));
    }
    ObjectDelta<UserType> userDelta = new ObjectDelta<>(UserType.class, ChangeType.MODIFY, prismContext);
    userDelta.setOid(USER_JACK_OID);
    userDelta.addModification(attributeDelta);
    addFocusDeltaToContext(context, userDelta);
}
Also used : ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) QName(javax.xml.namespace.QName) NameItemPathSegment(com.evolveum.midpoint.prism.path.NameItemPathSegment) IdItemPathSegment(com.evolveum.midpoint.prism.path.IdItemPathSegment) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 15 with ObjectFactory

use of com.evolveum.prism.xml.ns._public.query_3.ObjectFactory in project midpoint by Evolveum.

the class TestIteration method test200JackAssignAccountDummyPinkConflicting.

@Test
public void test200JackAssignAccountDummyPinkConflicting() throws Exception {
    final String TEST_NAME = "test200JackAssignAccountDummyPinkConflicting";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestIteration.class.getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    dummyAuditService.clear();
    // Make sure there is a conflicting account and also a shadow for it
    DummyAccount account = new DummyAccount(ACCOUNT_JACK_DUMMY_USERNAME);
    account.setEnabled(true);
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_FULLNAME_NAME, "Jack Pinky");
    account.addAttributeValues(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_LOCATION_NAME, "Red Sea");
    dummyResourcePink.addAccount(account);
    repoAddObject(createShadow(resourceDummyPink, ACCOUNT_JACK_DUMMY_USERNAME), result);
    Collection<ObjectDelta<? extends ObjectType>> deltas = new ArrayList<ObjectDelta<? extends ObjectType>>();
    // assignment with weapon := 'pistol' (test for
    Collection<ItemDelta<?, ?>> modifications = new ArrayList<>();
    AssignmentType assignmentType = createConstructionAssignment(RESOURCE_DUMMY_PINK_OID, ShadowKindType.ACCOUNT, null);
    ConstructionType constructionType = assignmentType.getConstruction();
    ResourceAttributeDefinitionType attributeDefinitionType = new ResourceAttributeDefinitionType();
    attributeDefinitionType.setRef(new ItemPathType(new ItemPath(dummyResourceCtlPink.getAttributeWeaponQName())));
    MappingType mappingType = new MappingType();
    mappingType.setStrength(MappingStrengthType.STRONG);
    ExpressionType expressionType = new ExpressionType();
    expressionType.getExpressionEvaluator().add(new ObjectFactory().createValue(RawType.create("pistol", prismContext)));
    mappingType.setExpression(expressionType);
    attributeDefinitionType.setOutbound(mappingType);
    constructionType.getAttribute().add(attributeDefinitionType);
    modifications.add(createAssignmentModification(assignmentType, true));
    ObjectDelta<UserType> accountAssignmentUserDelta = ObjectDelta.createModifyDelta(USER_JACK_OID, modifications, UserType.class, prismContext);
    deltas.add(accountAssignmentUserDelta);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    modelService.executeChanges(deltas, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    PrismObject<UserType> userJack = getUser(USER_JACK_OID);
    display("User after change execution", userJack);
    assertUserJack(userJack);
    assertLinks(userJack, 2);
    assertAccount(userJack, RESOURCE_DUMMY_OID);
    assertAccount(userJack, RESOURCE_DUMMY_PINK_OID);
    String accountPinkOid = getLinkRefOid(userJack, RESOURCE_DUMMY_PINK_OID);
    // Check shadow
    PrismObject<ShadowType> accountPinkShadow = repositoryService.getObject(ShadowType.class, accountPinkOid, null, result);
    assertAccountShadowRepo(accountPinkShadow, accountPinkOid, "jack1", resourceDummyPinkType);
    // Check account
    PrismObject<ShadowType> accountPinkModel = modelService.getObject(ShadowType.class, accountPinkOid, null, task, result);
    assertAccountShadowModel(accountPinkModel, accountPinkOid, "jack1", resourceDummyPinkType);
    display("accountPinkModel", accountPinkModel);
    PrismAsserts.assertPropertyValue(accountPinkModel, dummyResourceCtlPink.getAttributePath(DummyResourceContoller.DUMMY_ACCOUNT_ATTRIBUTE_WEAPON_NAME), "pistol");
    // Check account in dummy resource
    assertDefaultDummyAccount(ACCOUNT_JACK_DUMMY_USERNAME, "Jack Sparrow", true);
    // The original conflicting account should still remain
    assertDummyAccount(RESOURCE_DUMMY_PINK_NAME, ACCOUNT_JACK_DUMMY_USERNAME, "Jack Pinky", true);
    // The new account
    assertDummyAccount(RESOURCE_DUMMY_PINK_NAME, "jack1", "Jack Sparrow", true);
    // Check audit
    display("Audit", dummyAuditService);
    dummyAuditService.assertRecords(2);
    dummyAuditService.assertSimpleRecordSanity();
    dummyAuditService.assertAnyRequestDeltas();
    dummyAuditService.assertExecutionDeltas(3);
    dummyAuditService.assertHasDelta(ChangeType.MODIFY, UserType.class);
    dummyAuditService.assertHasDelta(ChangeType.ADD, ShadowType.class);
    dummyAuditService.assertExecutionSuccess();
}
Also used : MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) Task(com.evolveum.midpoint.task.api.Task) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) ItemPathType(com.evolveum.prism.xml.ns._public.types_3.ItemPathType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) ResourceAttributeDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ItemDelta(com.evolveum.midpoint.prism.delta.ItemDelta) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ObjectFactory(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) ExpressionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Aggregations

Test (org.junit.Test)14 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)13 JAXBElement (javax.xml.bind.JAXBElement)11 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)11 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)10 Marshaller (javax.xml.bind.Marshaller)8 ObjectFactory (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectFactory)7 StringWriter (java.io.StringWriter)7 JAXBContext (javax.xml.bind.JAXBContext)7 Holder (javax.xml.ws.Holder)7 ObjectFactory (org.apache.type_test.types3.ObjectFactory)7 ItemPathType (com.evolveum.prism.xml.ns._public.types_3.ItemPathType)6 BigInteger (java.math.BigInteger)6 ArrayList (java.util.ArrayList)6 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)6 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 XStream (com.thoughtworks.xstream.XStream)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Writer (java.io.Writer)5 QName (javax.xml.namespace.QName)5