Search in sources :

Example 6 with QName

use of javax.xml.namespace.QName in project midpoint by Evolveum.

the class ObjectBrowserPanel method initLayout.

private void initLayout(Class<? extends O> type, final List<QName> supportedTypes, final boolean multiselect) {
    WebMarkupContainer typePanel = new WebMarkupContainer(ID_TYPE_PANEL);
    typePanel.setOutputMarkupId(true);
    typePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return supportedTypes.size() != 1;
        }
    });
    add(typePanel);
    DropDownChoice<QName> typeSelect = new DropDownChoice<QName>(ID_TYPE, typeModel, new ListModel<QName>(supportedTypes), new QNameChoiceRenderer());
    typeSelect.add(new OnChangeAjaxBehavior() {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            ObjectListPanel<O> listPanel = (ObjectListPanel<O>) get(ID_TABLE);
            listPanel = createObjectListPanel(qnameToCompileTimeClass(typeModel.getObject()), multiselect);
            addOrReplace(listPanel);
            target.add(listPanel);
        }
    });
    typePanel.add(typeSelect);
    ObjectListPanel<O> listPanel = createObjectListPanel(type, multiselect);
    add(listPanel);
    AjaxButton addButton = new AjaxButton(ID_BUTTON_ADD, createStringResource("userBrowserDialog.button.addButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            List<O> selected = ((PopupObjectListPanel) getParent().get(ID_TABLE)).getSelectedObjects();
            QName type = ObjectBrowserPanel.this.typeModel.getObject();
            ObjectBrowserPanel.this.addPerformed(target, type, selected);
        }
    };
    addButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return multiselect;
        }
    });
    add(addButton);
}
Also used : QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) QName(javax.xml.namespace.QName) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 7 with QName

use of javax.xml.namespace.QName in project midpoint by Evolveum.

the class ExportAction method executeSearch.

private void executeSearch(ModelPortType port, Writer writer) throws FaultMessage, IOException, JAXBException, SAXException {
    SelectorQualifiedGetOptionsType options = createOptions();
    QName type = ObjectType.getType(getParams().getType());
    if (type == null) {
        type = ObjectType.OBJECT.getType();
    }
    int count = 0;
    int currentSize = 1;
    Holder<ObjectListType> list = new Holder<>();
    Holder<OperationResultType> result = new Holder<>();
    while (currentSize > 0) {
        QueryType query = createQuery(count);
        port.searchObjects(type, query, options, list, result);
        OperationResultType res = result.value;
        if (!OperationResultStatusType.SUCCESS.equals(res.getStatus()) && !getParams().isIgnore()) {
            printInfoMessage("Search returned {}, reason: ", res.getStatus(), res.getMessage());
            if (getParams().isVerbose()) {
                printInfoMessage("Operation result:\n{}", ToolsUtils.serializeObject(res));
            }
            break;
        }
        ObjectListType objList = list.value;
        if (getParams().isVerbose()) {
            printInfoMessage("Search returned {}, status: {}/{}", res.getStatus(), count, objList.getCount());
        }
        List<com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> objects = objList.getObject();
        currentSize = objects.size();
        for (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType object : objects) {
            ToolsUtils.serializeObject(object, writer);
            writer.write('\n');
        }
        count += currentSize;
    }
}
Also used : QName(javax.xml.namespace.QName) Holder(javax.xml.ws.Holder) ObjectListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType) ObjectType(com.evolveum.midpoint.cli.ninja.util.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) QueryType(com.evolveum.prism.xml.ns._public.query_3.QueryType) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 8 with QName

use of javax.xml.namespace.QName in project midpoint by Evolveum.

the class ExportAction method executeGet.

private void executeGet(ModelPortType port, Writer writer) throws FaultMessage, IOException, JAXBException {
    SelectorQualifiedGetOptionsType options = createOptions();
    QName type = ObjectType.getType(getParams().getType());
    if (type == null) {
        type = ObjectType.OBJECT.getType();
    }
    Holder<com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType> object = new Holder<>();
    Holder<OperationResultType> result = new Holder<>();
    port.getObject(type, getParams().getOid(), options, object, result);
    ToolsUtils.serializeObject(object.value, writer);
}
Also used : ObjectType(com.evolveum.midpoint.cli.ninja.util.ObjectType) QName(javax.xml.namespace.QName) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) SelectorQualifiedGetOptionsType(com.evolveum.midpoint.xml.ns._public.common.common_3.SelectorQualifiedGetOptionsType)

Example 9 with QName

use of javax.xml.namespace.QName in project midpoint by Evolveum.

the class ResourceAssociationEditor method loadObjectReferences.

private List<QName> loadObjectReferences(boolean restrictObjectClass) {
    List<QName> references = new ArrayList<>();
    ResourceSchema schema = loadResourceSchema();
    if (schema == null) {
        return references;
    }
    for (ObjectClassComplexTypeDefinition def : schema.getObjectClassDefinitions()) {
        if (restrictObjectClass) {
            if (objectType != null && def.getTypeName().equals(objectType.getObjectClass())) {
                for (ResourceAttributeDefinition attributeDefinition : def.getAttributeDefinitions()) {
                    references.add(attributeDefinition.getName());
                }
            }
        } else {
            for (ResourceAttributeDefinition attributeDefinition : def.getAttributeDefinitions()) {
                references.add(attributeDefinition.getName());
            }
        }
    }
    return references;
}
Also used : ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) ResourceAttributeDefinition(com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)

Example 10 with QName

use of javax.xml.namespace.QName in project midpoint by Evolveum.

the class AbstractLexicalProcessorTest method testParseUserRoundTrip.

@Test
public void testParseUserRoundTrip() throws Exception {
    final String TEST_NAME = "testParseUserRoundTrip";
    displayTestTitle(TEST_NAME);
    // GIVEN
    LexicalProcessor<String> lexicalProcessor = createParser();
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN (parse)
    RootXNode xnode = lexicalProcessor.read(getFileSource(USER_JACK_FILE_BASENAME), ParsingContext.createDefault());
    System.out.println("\nParsed xnode:");
    System.out.println(xnode.debugDump());
    PrismObject<UserType> user = prismContext.parserFor(xnode).parse();
    // THEN
    System.out.println("\nParsed user:");
    System.out.println(user.debugDump());
    assertUserJack(user, true);
    // WHEN (re-serialize to XNode)
    RootXNode serializedXNode = prismContext.xnodeSerializer().options(SerializationOptions.createSerializeCompositeObjects()).serialize(user);
    String serializedString = lexicalProcessor.write(serializedXNode, new QName(NS_FOO, "user"), null);
    // THEN
    System.out.println("\nXNode after re-serialization:");
    System.out.println(serializedXNode.debugDump());
    System.out.println("\nRe-serialized string:");
    System.out.println(serializedString);
    String whenSerialized = getWhenItemSerialized();
    assertTrue("Serialized form does not contain " + whenSerialized, serializedString.contains(whenSerialized));
    assertUserJackXNodeOrdering("serialized xnode", serializedXNode);
    validateUserSchema(serializedString, prismContext);
    // WHEN (re-parse)
    RootXNode reparsedXnode = lexicalProcessor.read(new ParserStringSource(serializedString), ParsingContext.createDefault());
    PrismObject<UserType> reparsedUser = prismContext.parserFor(reparsedXnode).parse();
    // THEN
    System.out.println("\nXNode after re-parsing:");
    System.out.println(reparsedXnode.debugDump());
    System.out.println("\nRe-parsed user:");
    System.out.println(reparsedUser.debugDump());
    assertUserJackXNodeOrdering("serialized xnode", reparsedXnode);
    ObjectDelta<UserType> diff = DiffUtil.diff(user, reparsedUser);
    System.out.println("\nDiff:");
    System.out.println(diff.debugDump());
    PrismObject accountRefObjOrig = findObjectFromAccountRef(user);
    PrismObject accountRefObjRe = findObjectFromAccountRef(reparsedUser);
    ObjectDelta<UserType> accountRefObjDiff = DiffUtil.diff(accountRefObjOrig, accountRefObjRe);
    System.out.println("\naccountRef object diff:");
    System.out.println(accountRefObjDiff.debugDump());
    assertTrue("Re-parsed object in accountRef does not match: " + accountRefObjDiff, accountRefObjDiff.isEmpty());
    assertTrue("Re-parsed user does not match: " + diff, diff.isEmpty());
}
Also used : QName(javax.xml.namespace.QName) RootXNode(com.evolveum.midpoint.prism.xnode.RootXNode) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.prism.foo.UserType) Test(org.testng.annotations.Test)

Aggregations

QName (javax.xml.namespace.QName)6720 Test (org.junit.Test)1407 URL (java.net.URL)1197 Service (javax.xml.ws.Service)1052 ArrayList (java.util.ArrayList)858 Bus (org.apache.cxf.Bus)486 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)462 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)395 Test (org.testng.annotations.Test)357 HashMap (java.util.HashMap)351 OMElement (org.apache.axiom.om.OMElement)344 Element (org.w3c.dom.Element)312 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)292 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)289 JBossWSTest (org.jboss.wsf.test.JBossWSTest)272 Document (org.w3c.dom.Document)263 List (java.util.List)240 IOException (java.io.IOException)218 InputStream (java.io.InputStream)218 JAXBElement (javax.xml.bind.JAXBElement)218