ClassificationScheme scheme = null;
if (namePatterns.indexOf("uddi-org:types") != -1) {
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_TYPES_TMODEL_KEY));
}
else if (namePatterns.indexOf("dnb-com:D-U-N-S") != -1) {
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_D_U_N_S_TMODEL_KEY));
}
else if (namePatterns.indexOf("uddi-org:iso-ch:3166:1999") != -1)
{
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
}
else if (namePatterns.indexOf("uddi-org:iso-ch:3166-1999") != -1)
{
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
}
else if (namePatterns.indexOf("iso-ch:3166:1999") != -1)
{
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
}
else if (namePatterns.indexOf("iso-ch:3166-1999") != -1)
{
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_ISO_CH_TMODEL_KEY));
}
else if (namePatterns.indexOf("unspsc-org:unspsc") != -1) {
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
}
else if (namePatterns.indexOf("ntis-gov:naics") != -1) {
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_NAICS_TMODEL_KEY));
}
else
{ //TODO:Before going to the registry, check if it a predefined Enumeration
/*
* predefined Enumerations
*/
if ("AssociationType".equals(namePatterns)) {
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
addChildConcept((ClassificationSchemeImpl)scheme, "RelatedTo");
addChildConcept((ClassificationSchemeImpl)scheme, "HasChild");
addChildConcept((ClassificationSchemeImpl)scheme, "HasMember");
addChildConcept((ClassificationSchemeImpl)scheme, "HasParent");
addChildConcept((ClassificationSchemeImpl)scheme, "ExternallyLinks");
addChildConcept((ClassificationSchemeImpl)scheme, "Contains");
addChildConcept((ClassificationSchemeImpl)scheme, "EquivalentTo");
addChildConcept((ClassificationSchemeImpl)scheme, "Extends");
addChildConcept((ClassificationSchemeImpl)scheme, "Implements");
addChildConcept((ClassificationSchemeImpl)scheme, "InstanceOf");
addChildConcept((ClassificationSchemeImpl)scheme, "Supersedes");
addChildConcept((ClassificationSchemeImpl)scheme, "Uses");
addChildConcept((ClassificationSchemeImpl)scheme, "Replaces");
addChildConcept((ClassificationSchemeImpl)scheme, "ResponsibleFor");
addChildConcept((ClassificationSchemeImpl)scheme, "SubmitterOf");
}
else if ("ObjectType".equals(namePatterns)) {
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
addChildConcept((ClassificationSchemeImpl)scheme, "CPP");
addChildConcept((ClassificationSchemeImpl)scheme, "CPA");
addChildConcept((ClassificationSchemeImpl)scheme, "Process");
addChildConcept((ClassificationSchemeImpl)scheme, "WSDL");
addChildConcept((ClassificationSchemeImpl)scheme, "Association");
addChildConcept((ClassificationSchemeImpl)scheme, "AuditableEvent");
addChildConcept((ClassificationSchemeImpl)scheme, "Classification");
addChildConcept((ClassificationSchemeImpl)scheme, "Concept");
addChildConcept((ClassificationSchemeImpl)scheme, "ExternalIdentifier");
addChildConcept((ClassificationSchemeImpl)scheme, "ExternalLink");
addChildConcept((ClassificationSchemeImpl)scheme, "ExtrinsicObject");
addChildConcept((ClassificationSchemeImpl)scheme, "Organization");
addChildConcept((ClassificationSchemeImpl)scheme, "Package");
addChildConcept((ClassificationSchemeImpl)scheme, "Service");
addChildConcept((ClassificationSchemeImpl)scheme, "ServiceBinding");
addChildConcept((ClassificationSchemeImpl)scheme, "User");
}
else if ("PhoneType".equals(namePatterns)) {
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
addChildConcept((ClassificationSchemeImpl)scheme, "OfficePhone");
addChildConcept((ClassificationSchemeImpl)scheme, "HomePhone");
addChildConcept((ClassificationSchemeImpl)scheme, "MobilePhone");
addChildConcept((ClassificationSchemeImpl)scheme, "Beeper");
addChildConcept((ClassificationSchemeImpl)scheme, "FAX");
}
else if ("URLType".equals(namePatterns)) {
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
addChildConcept((ClassificationSchemeImpl)scheme, "HTTP");
addChildConcept((ClassificationSchemeImpl)scheme, "HTTPS");
addChildConcept((ClassificationSchemeImpl)scheme, "SMTP");
addChildConcept((ClassificationSchemeImpl)scheme, "PHONE");
addChildConcept((ClassificationSchemeImpl)scheme, "FAX");
addChildConcept((ClassificationSchemeImpl)scheme, "OTHER");
}
else if ("PostalAddressAttributes".equals(namePatterns)) {
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(namePatterns));
scheme.setKey(new KeyImpl(Constants.TMODEL_UNSPSC_TMODEL_KEY));
addChildConcept((ClassificationSchemeImpl)scheme, "StreetNumber");
addChildConcept((ClassificationSchemeImpl)scheme, "Street");
addChildConcept((ClassificationSchemeImpl)scheme, "City");
addChildConcept((ClassificationSchemeImpl)scheme, "State");
addChildConcept((ClassificationSchemeImpl)scheme, "PostalCode");
addChildConcept((ClassificationSchemeImpl)scheme, "Country");
}
else {
//Lets ask the uddi registry if it has the TModels
IRegistryV3 registry = (IRegistryV3) registryService.getRegistry();
FindQualifiers juddiFindQualifiers = mapFindQualifiers(findQualifiers);
try
{
//We are looking for one exact match, so getting upto 3 records is fine
TModelList list = registry.findTModel(namePatterns, null, null, juddiFindQualifiers, 3);
if (list != null) {
TModelInfos infos = list.getTModelInfos();
if (infos != null) {
List<TModelInfo> tmodelInfoList = infos.getTModelInfo();
if (tmodelInfoList.size() > 1) {
throw new InvalidRequestException("Multiple matches found:" + tmodelInfoList.size());
}
if (tmodelInfoList.size() ==1) {
TModelInfo info = tmodelInfoList.get(0);
scheme = new ClassificationSchemeImpl(registryService.getLifeCycleManagerImpl());
scheme.setName(new InternationalStringImpl(info.getName().getValue()));
scheme.setKey(new KeyImpl(info.getTModelKey()));
}
}
}