Example usage for javax.xml.registry.infomodel Concept setValue

List of usage examples for javax.xml.registry.infomodel Concept setValue

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel Concept setValue.

Prototype

void setValue(String value) throws JAXRException;

Source Link

Document

Sets the value (usually a taxonomy value) associated with this Concept.

Usage

From source file:org.apache.ws.scout.registry.BusinessLifeCycleManagerImpl.java

public BulkResponse saveAssociations(Collection associations, boolean replace) throws JAXRException {
    BulkResponseImpl bulk = new BulkResponseImpl();
    PublisherAssertion[] sarr = new PublisherAssertion[associations.size()];

    Collection<Key> coll = new ArrayList<Key>();
    Collection<Exception> exceptions = new ArrayList<Exception>();

    Iterator iter = associations.iterator();
    int currLoc = 0;
    while (iter.hasNext()) {

        Association association = (Association) iter.next();
        association.getSourceObject();/*from w w  w  .  j  a  v  a 2 s  . c  om*/
        PublisherAssertion pa = ScoutJaxrUddiHelper.getPubAssertionFromJAXRAssociation(association);
        sarr[currLoc] = pa;
        currLoc++;

        // Save PublisherAssertion
        PublisherAssertions bd = null;
        try {
            bd = (PublisherAssertions) executeOperation(sarr, "SAVE_ASSOCIATION");
        } catch (RegistryException e) {
            exceptions.add(new SaveException(e));
            bulk.setExceptions(exceptions);
            bulk.setStatus(JAXRResponse.STATUS_FAILURE);
            return bulk;
        }
        if (bd != null) {
            List<PublisherAssertion> publisherAssertionList = bd.getPublisherAssertion();
            PublisherAssertion[] keyarr = new PublisherAssertion[publisherAssertionList.size()];
            publisherAssertionList.toArray(keyarr);

            for (int i = 0; keyarr != null && i < keyarr.length; i++) {
                PublisherAssertion result = (PublisherAssertion) keyarr[i];
                KeyedReference keyr = result.getKeyedReference();
                Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
                c.setName(new InternationalStringImpl(keyr.getKeyName()));
                c.setKey(new KeyImpl(keyr.getTModelKey()));
                c.setValue(keyr.getKeyValue());
                association.setAssociationType(c);
                coll.add(association.getKey());
            }
        }
    }
    bulk.setCollection(coll);
    bulk.setExceptions(exceptions);

    return bulk;
}

From source file:org.apache.ws.scout.registry.BusinessLifeCycleManagerV3Impl.java

public BulkResponse saveAssociations(Collection associations, boolean replace) throws JAXRException {
    BulkResponseImpl bulk = new BulkResponseImpl();
    PublisherAssertion[] sarr = new PublisherAssertion[associations.size()];

    Collection<Key> coll = new ArrayList<Key>();
    Collection<Exception> exceptions = new ArrayList<Exception>();

    Iterator iter = associations.iterator();
    int currLoc = 0;
    while (iter.hasNext()) {

        Association association = (Association) iter.next();
        association.getSourceObject();/*from www . j ava  2s . com*/
        PublisherAssertion pa = ScoutJaxrUddiV3Helper.getPubAssertionFromJAXRAssociation(association);
        sarr[currLoc] = pa;
        currLoc++;

        // Save PublisherAssertion
        PublisherAssertions bd = null;
        try {
            bd = (PublisherAssertions) executeOperation(sarr, "SAVE_ASSOCIATION");
        } catch (RegistryV3Exception e) {
            exceptions.add(new SaveException(e));
            bulk.setExceptions(exceptions);
            bulk.setStatus(JAXRResponse.STATUS_FAILURE);
            return bulk;
        }
        if (bd != null) {
            List<PublisherAssertion> publisherAssertionList = bd.getPublisherAssertion();
            PublisherAssertion[] keyarr = new PublisherAssertion[publisherAssertionList.size()];
            publisherAssertionList.toArray(keyarr);

            for (int i = 0; keyarr != null && i < keyarr.length; i++) {
                PublisherAssertion result = (PublisherAssertion) keyarr[i];
                KeyedReference keyr = result.getKeyedReference();
                Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
                c.setName(new InternationalStringImpl(keyr.getKeyName()));
                c.setKey(new KeyImpl(keyr.getTModelKey()));
                c.setValue(keyr.getKeyValue());
                association.setAssociationType(c);
                coll.add(association.getKey());
            }
        }
    }
    bulk.setCollection(coll);
    bulk.setExceptions(exceptions);

    return bulk;
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerImpl.java

public BulkResponse findAssociations(Collection findQualifiers, String sourceObjectId, String targetObjectId,
        Collection associationTypes) throws JAXRException {
    //TODO: Currently we just return all the Association objects owned by the caller
    IRegistry registry = (IRegistry) registryService.getRegistry();
    try {//from w w  w.  j  av  a  2s. c o  m
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);
        PublisherAssertions result = null;
        try {
            result = registry.getPublisherAssertions(auth.getAuthInfo());
        } catch (RegistryException rve) {
            String username = getUsernameFromCredentials(con.getCredentials());
            if (AuthTokenSingleton.getToken(username) != null) {
                AuthTokenSingleton.deleteAuthToken(username);
            }
            auth = getAuthToken(con, registry);
            result = registry.getPublisherAssertions(auth.getAuthInfo());
        }

        List<PublisherAssertion> publisherAssertionList = result.getPublisherAssertion();
        LinkedHashSet<Association> col = new LinkedHashSet<Association>();
        for (PublisherAssertion pas : publisherAssertionList) {
            String sourceKey = pas.getFromKey();
            String targetKey = pas.getToKey();

            if ((sourceObjectId == null || sourceObjectId.equals(sourceKey))
                    && (targetObjectId == null || targetObjectId.equals(targetKey))) {
                Collection<Key> orgcol = new ArrayList<Key>();
                orgcol.add(new KeyImpl(sourceKey));
                orgcol.add(new KeyImpl(targetKey));
                BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
                Association asso = ScoutUddiJaxrHelper.getAssociation(bl.getCollection(),
                        registryService.getBusinessLifeCycleManager());
                KeyedReference keyr = pas.getKeyedReference();
                Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
                c.setName(new InternationalStringImpl(keyr.getKeyName()));
                c.setKey(new KeyImpl(keyr.getTModelKey()));
                c.setValue(keyr.getKeyValue());
                asso.setAssociationType(c);
                col.add(asso);
            }

        }
        return new BulkResponseImpl(col);
    } catch (RegistryException e) {
        throw new JAXRException(e);
    }
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerImpl.java

public BulkResponse findCallerAssociations(Collection findQualifiers, Boolean confirmedByCaller,
        Boolean confirmedByOtherParty, Collection associationTypes) throws JAXRException {
    //TODO: Currently we just return all the Association objects owned by the caller
    IRegistry registry = (IRegistry) registryService.getRegistry();
    try {/*from w w w . ja va  2s  .c o m*/
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);

        AssertionStatusReport report = null;
        String confirm = "";
        boolean caller = confirmedByCaller.booleanValue();
        boolean other = confirmedByOtherParty.booleanValue();

        if (caller && other)
            confirm = Constants.COMPLETION_STATUS_COMPLETE;
        else if (!caller && other)
            confirm = Constants.COMPLETION_STATUS_FROMKEY_INCOMPLETE;
        else if (caller && !other)
            confirm = Constants.COMPLETION_STATUS_TOKEY_INCOMPLETE;

        report = null;
        try {
            report = registry.getAssertionStatusReport(auth.getAuthInfo(), confirm);
        } catch (RegistryException rve) {
            String username = getUsernameFromCredentials(con.getCredentials());
            if (AuthTokenSingleton.getToken(username) != null) {
                AuthTokenSingleton.deleteAuthToken(username);
            }
            auth = getAuthToken(con, registry);
            report = registry.getAssertionStatusReport(auth.getAuthInfo(), confirm);
        }

        List<AssertionStatusItem> assertionStatusItemList = report.getAssertionStatusItem();
        LinkedHashSet<Association> col = new LinkedHashSet<Association>();
        for (AssertionStatusItem asi : assertionStatusItemList) {
            String sourceKey = asi.getFromKey();
            String targetKey = asi.getToKey();
            Collection<Key> orgcol = new ArrayList<Key>();
            orgcol.add(new KeyImpl(sourceKey));
            orgcol.add(new KeyImpl(targetKey));
            BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
            Association asso = ScoutUddiJaxrHelper.getAssociation(bl.getCollection(),
                    registryService.getBusinessLifeCycleManager());
            //Set Confirmation
            ((AssociationImpl) asso).setConfirmedBySourceOwner(caller);
            ((AssociationImpl) asso).setConfirmedByTargetOwner(other);

            if (confirm != Constants.COMPLETION_STATUS_COMPLETE)
                ((AssociationImpl) asso).setConfirmed(false);

            Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
            KeyedReference keyr = asi.getKeyedReference();
            c.setKey(new KeyImpl(keyr.getTModelKey()));
            c.setName(new InternationalStringImpl(keyr.getKeyName()));
            c.setValue(keyr.getKeyValue());
            asso.setKey(new KeyImpl(keyr.getTModelKey())); //TODO:Validate this
            asso.setAssociationType(c);
            col.add(asso);
        }

        return new BulkResponseImpl(col);
    } catch (RegistryException e) {
        throw new JAXRException(e);
    }
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerImpl.java

/**
 * Creates a new Concept, associates w/ parent scheme, and then
 * adds as decendent.//from ww w.j a va  2  s  .c om
 * @param scheme
 * @param name
 * @throws JAXRException
 */
private void addChildConcept(ClassificationSchemeImpl scheme, String name) throws JAXRException {
    Concept c = new ConceptImpl(registryService.getLifeCycleManagerImpl());

    c.setName(new InternationalStringImpl(name));
    c.setValue(name);
    ((ConceptImpl) c).setScheme((ClassificationSchemeImpl) scheme);

    scheme.addChildConcept(c);
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerV3Impl.java

public BulkResponse findAssociations(Collection findQualifiers, String sourceObjectId, String targetObjectId,
        Collection associationTypes) throws JAXRException {
    //TODO: Currently we just return all the Association objects owned by the caller
    IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
    try {/*  w  w w  .  jav  a 2  s .c  o m*/
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);
        PublisherAssertions result = null;
        try {
            result = registry.getPublisherAssertions(auth.getAuthInfo());
        } catch (RegistryV3Exception rve) {
            String username = getUsernameFromCredentials(con.getCredentials());
            if (AuthTokenV3Singleton.getToken(username) != null) {
                AuthTokenV3Singleton.deleteAuthToken(username);
            }
            auth = getAuthToken(con, registry);
            result = registry.getPublisherAssertions(auth.getAuthInfo());
        }

        List<PublisherAssertion> publisherAssertionList = result.getPublisherAssertion();
        LinkedHashSet<Association> col = new LinkedHashSet<Association>();
        for (PublisherAssertion pas : publisherAssertionList) {
            String sourceKey = pas.getFromKey();
            String targetKey = pas.getToKey();
            Collection<Key> orgcol = new ArrayList<Key>();
            orgcol.add(new KeyImpl(sourceKey));
            orgcol.add(new KeyImpl(targetKey));
            BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
            Association asso = ScoutUddiV3JaxrHelper.getAssociation(bl.getCollection(),
                    registryService.getBusinessLifeCycleManager());
            KeyedReference keyr = pas.getKeyedReference();
            Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
            c.setName(new InternationalStringImpl(keyr.getKeyName()));
            c.setKey(new KeyImpl(keyr.getTModelKey()));
            c.setValue(keyr.getKeyValue());
            asso.setAssociationType(c);
            col.add(asso);
        }
        return new BulkResponseImpl(col);
    } catch (RegistryV3Exception e) {
        throw new JAXRException(e);
    }
}

From source file:org.apache.ws.scout.registry.BusinessQueryManagerV3Impl.java

public BulkResponse findCallerAssociations(Collection findQualifiers, Boolean confirmedByCaller,
        Boolean confirmedByOtherParty, Collection associationTypes) throws JAXRException {
    //TODO: Currently we just return all the Association objects owned by the caller
    IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
    try {//  ww w .ja v a 2 s. c  om
        ConnectionImpl con = ((RegistryServiceImpl) getRegistryService()).getConnection();
        AuthToken auth = this.getAuthToken(con, registry);

        AssertionStatusReport report = null;
        String confirm = "";
        boolean caller = confirmedByCaller.booleanValue();
        boolean other = confirmedByOtherParty.booleanValue();

        if (caller && other)
            confirm = Constants.COMPLETION_STATUS_COMPLETE;
        else if (!caller && other)
            confirm = Constants.COMPLETION_STATUS_FROMKEY_INCOMPLETE;
        else if (caller && !other)
            confirm = Constants.COMPLETION_STATUS_TOKEY_INCOMPLETE;

        try {
            report = registry.getAssertionStatusReport(auth.getAuthInfo(), confirm);
        } catch (RegistryV3Exception rve) {
            String username = getUsernameFromCredentials(con.getCredentials());
            if (AuthTokenV3Singleton.getToken(username) != null) {
                AuthTokenV3Singleton.deleteAuthToken(username);
            }
            auth = getAuthToken(con, registry);
            report = registry.getAssertionStatusReport(auth.getAuthInfo(), confirm);
        }

        List<AssertionStatusItem> assertionStatusItemList = report.getAssertionStatusItem();
        LinkedHashSet<Association> col = new LinkedHashSet<Association>();
        for (AssertionStatusItem asi : assertionStatusItemList) {
            String sourceKey = asi.getFromKey();
            String targetKey = asi.getToKey();
            Collection<Key> orgcol = new ArrayList<Key>();
            orgcol.add(new KeyImpl(sourceKey));
            orgcol.add(new KeyImpl(targetKey));
            BulkResponse bl = getRegistryObjects(orgcol, LifeCycleManager.ORGANIZATION);
            Association asso = ScoutUddiV3JaxrHelper.getAssociation(bl.getCollection(),
                    registryService.getBusinessLifeCycleManager());
            //Set Confirmation
            ((AssociationImpl) asso).setConfirmedBySourceOwner(caller);
            ((AssociationImpl) asso).setConfirmedByTargetOwner(other);

            if (confirm != Constants.COMPLETION_STATUS_COMPLETE)
                ((AssociationImpl) asso).setConfirmed(false);

            Concept c = new ConceptImpl(getRegistryService().getBusinessLifeCycleManager());
            KeyedReference keyr = asi.getKeyedReference();
            c.setKey(new KeyImpl(keyr.getTModelKey()));
            c.setName(new InternationalStringImpl(keyr.getKeyName()));
            c.setValue(keyr.getKeyValue());
            asso.setKey(new KeyImpl(keyr.getTModelKey())); //TODO:Validate this
            asso.setAssociationType(c);
            col.add(asso);
        }

        return new BulkResponseImpl(col);
    } catch (RegistryV3Exception e) {
        throw new JAXRException(e);
    }
}

From source file:org.apache.ws.scout.util.EnumerationHelper.java

/**
 * //w  ww .  ja va  2  s.  c o m
 * @param firstToken
 * @param secondToken
 * @return Concept
 * @throws JAXRException
 */
private static Concept createConcept(String firstToken, String secondToken)
        throws JAXRException, IllegalArgumentException {
    if (!TYPES_LIST.contains(firstToken))
        throw new IllegalArgumentException("Expected the path to " + "start with one of " + TYPES);

    //get the predefined classificationscheme
    ClassificationScheme cs = new ClassificationSchemeImpl(null);
    cs.setName(new InternationalStringImpl(firstToken));
    cs.setKey(new KeyImpl(firstToken));

    ArrayList<String> conceptStrings = typesMap.get(firstToken);
    if (!conceptStrings.contains(secondToken))
        throw new IllegalArgumentException(
                "Expected the path to " + "end with one of " + conceptStrings.toArray());

    Concept concept = new ConceptImpl(null);
    concept.setName(new InternationalStringImpl(secondToken.toLowerCase()));
    concept.setValue(secondToken);
    concept.setKey(new KeyImpl(UDDI_ORG_TYPES));
    ((ConceptImpl) concept).setScheme(((ClassificationSchemeImpl) cs));
    return concept;
}