Example usage for javax.xml.registry.infomodel Classification isExternal

List of usage examples for javax.xml.registry.infomodel Classification isExternal

Introduction

In this page you can find the example usage for javax.xml.registry.infomodel Classification isExternal.

Prototype

boolean isExternal() throws JAXRException;

Source Link

Document

Returns true if this is an external classification.

Usage

From source file:it.cnr.icar.eric.client.xml.registry.BusinessQueryManagerImpl.java

@SuppressWarnings("unused")
static private String classificationToConceptId(Object obj) throws JAXRException {
    if (!(obj instanceof Classification)) {
        throw new UnexpectedObjectException(JAXRResourceBundle.getInstance()
                .getString("message.error.expected.collection.objectType.Classification"));
    }// w  w w.  j  ava  2  s.c o  m

    Classification cl = (Classification) obj;

    if (cl.isExternal()) {
        throw new JAXRException(JAXRResourceBundle.getInstance()
                .getString("message.error.no.support.external.classification.qaulifier"));
    }

    Concept concept = cl.getConcept();

    if (concept == null) {
        throw new JAXRException(JAXRResourceBundle.getInstance()
                .getString("message.error.internal.classification.concept.null"));
    }

    return concept.getKey().getId();
}

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

/**
  * According to JAXR Javadoc, there are two types of classification, internal and external and they use the Classification, Concept,     
  * and ClassificationScheme objects.  It seems the only difference between internal and external (as related to UDDI) is that the
  * name/value pair of the categorization is held in the Concept for internal classifications and the Classification for external (bypassing
  * the Concept entirely)./*from   www  .j a  va  2s.  c  o  m*/
  * 
  * The translation to UDDI is simple.  Relevant objects have a category bag which contains a bunch of KeyedReferences (name/value pairs).  
  * These KeyedReferences optionally refer to a tModel that identifies the type of category (translates to the ClassificationScheme key).  If
  * this is set and the tModel doesn't exist in the UDDI registry, then an invalid key error will occur when trying to save the object.
  * 
  * @param classifications classifications to turn into categories
  * @throws JAXRException
  */
public static CategoryBag getCategoryBagFromClassifications(Collection classifications) throws JAXRException {
    try {
        if (classifications == null || classifications.size() == 0)
            return null;

        // Classifications
        CategoryBag cbag = objectFactory.createCategoryBag();
        Iterator classiter = classifications.iterator();
        while (classiter.hasNext()) {
            Classification classification = (Classification) classiter.next();
            if (classification != null) {
                KeyedReference keyr = objectFactory.createKeyedReference();
                cbag.getKeyedReference().add(keyr);

                InternationalStringImpl iname = null;
                String value = null;
                ClassificationScheme scheme = classification.getClassificationScheme();
                if (scheme == null || (classification.isExternal() && classification.getConcept() == null)) {
                    /*
                    * JAXR 1.0 Specification: Section D6.4.4
                    * Specification related tModels mapped from Concept may be automatically
                    * categorized by the well-known uddi-org:types taxonomy in UDDI (with
                    * tModelKey uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4) as follows:
                    * The keyed reference is assigned a taxonomy value of specification.
                    */
                    keyr.setTModelKey(UDDI_ORG_TYPES);
                    keyr.setKeyValue("specification");
                } else {
                    if (classification.isExternal()) {
                        iname = (InternationalStringImpl) ((RegistryObject) classification).getName();
                        value = classification.getValue();
                    } else {
                        Concept concept = classification.getConcept();
                        if (concept != null) {
                            iname = (InternationalStringImpl) ((RegistryObject) concept).getName();
                            value = concept.getValue();
                            scheme = concept.getClassificationScheme();
                        }
                    }

                    String name = iname.getValue();
                    if (name != null)
                        keyr.setKeyName(name);

                    if (value != null)
                        keyr.setKeyValue(value);

                    if (scheme != null) {
                        Key key = scheme.getKey();
                        if (key != null && key.getId() != null)
                            keyr.setTModelKey(key.getId());
                    }
                }
            }
        }
        return cbag;
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
}

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

/**
  * According to JAXR Javadoc, there are two types of classification, internal and external and they use the Classification, Concept,     
  * and ClassificationScheme objects.  It seems the only difference between internal and external (as related to UDDI) is that the
  * name/value pair of the categorization is held in the Concept for internal classifications and the Classification for external (bypassing
  * the Concept entirely)./*from  w  ww  . ja va2 s .co  m*/
  * 
  * The translation to UDDI is simple.  Relevant objects have a category bag which contains a bunch of KeyedReferences (name/value pairs).  
  * These KeyedReferences optionally refer to a tModel that identifies the type of category (translates to the ClassificationScheme key).  If
  * this is set and the tModel doesn't exist in the UDDI registry, then an invalid key error will occur when trying to save the object.
  * 
  * @param classifications classifications to turn into categories
  * @throws JAXRException
  */
public static CategoryBag getCategoryBagFromClassifications(Collection classifications) throws JAXRException {
    try {
        if (classifications == null || classifications.size() == 0)
            return null;

        // Classifications
        CategoryBag cbag = objectFactory.createCategoryBag();
        Iterator classiter = classifications.iterator();
        while (classiter.hasNext()) {
            Classification classification = (Classification) classiter.next();
            if (classification != null) {
                KeyedReference keyr = objectFactory.createKeyedReference();
                cbag.getKeyedReference().add(keyr);

                InternationalStringImpl iname = null;
                String value = null;
                ClassificationScheme scheme = classification.getClassificationScheme();
                if (scheme == null || (classification.isExternal() && classification.getConcept() == null)) {
                    /*
                    * JAXR 1.0 Specification: Section D6.4.4
                    * Specification related tModels mapped from Concept may be automatically
                    * categorized by the well-known uddi-org:types taxonomy in UDDI (with
                    * tModelKey uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4) as follows:
                    * The keyed reference is assigned a taxonomy value of specification.
                    */
                    keyr.setTModelKey(UDDI_ORG_TYPES);
                    keyr.setKeyValue("specification");
                } else {
                    if (classification.isExternal()) {
                        iname = (InternationalStringImpl) ((RegistryObject) classification).getName();
                        value = classification.getValue();
                    } else {
                        Concept concept = classification.getConcept();
                        if (concept != null) {
                            iname = (InternationalStringImpl) ((RegistryObject) concept).getName();
                            value = concept.getValue();
                            scheme = concept.getClassificationScheme();
                        }
                    }

                    String name = iname.getValue();
                    if (name != null)
                        keyr.setKeyName(name);

                    if (value != null)
                        keyr.setKeyValue(value);

                    if (scheme != null) {
                        Key key = scheme.getKey();
                        if (key != null && key.getId() != null)
                            keyr.setTModelKey(key.getId());
                    }
                }
            }
        }
        if (cbag.getKeyedReference().isEmpty())
            return null;
        else
            return cbag;
    } catch (Exception ud) {
        throw new JAXRException("Apache JAXR Impl:", ud);
    }
}