List of usage examples for java.util LinkedHashSet add
boolean add(E e);
From source file:org.apache.ws.scout.registry.BusinessLifeCycleManagerV3Impl.java
public BulkResponse saveConcepts(Collection concepts) throws JAXRException { //Now we need to convert the collection into a vector for juddi BulkResponseImpl bulk = new BulkResponseImpl(); TModel[] entityarr = new TModel[concepts.size()]; LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); Collection<Exception> exceptions = new ArrayList<Exception>(); Iterator iter = concepts.iterator(); int currLoc = 0; while (iter.hasNext()) { try {/*from w w w .j a v a 2 s. c om*/ TModel en = ScoutJaxrUddiV3Helper.getTModelFromJAXRConcept((Concept) iter.next()); entityarr[currLoc] = en; currLoc++; } catch (ClassCastException ce) { throw new UnexpectedObjectException(); } } log.debug("Method:save_concept: ENlength=" + entityarr.length); // Save business TModelDetail td = null; try { td = (TModelDetail) executeOperation(entityarr, "SAVE_TMODEL"); } catch (RegistryV3Exception e) { exceptions.add(new SaveException(e.getLocalizedMessage())); bulk.setStatus(JAXRResponse.STATUS_FAILURE); return bulk; } List<TModel> tmodelList = td.getTModel(); entityarr = new TModel[tmodelList.size()]; tmodelList.toArray(entityarr); log.debug("After Saving TModel. Obtained vector size:" + entityarr != null ? entityarr.length : 0); for (int i = 0; entityarr != null && i < entityarr.length; i++) { TModel tm = (TModel) entityarr[i]; coll.add(new KeyImpl(tm.getTModelKey())); } bulk.setCollection(coll); bulk.setExceptions(exceptions); return bulk; }
From source file:org.apache.ws.scout.registry.BusinessLifeCycleManagerImpl.java
public BulkResponse saveClassificationSchemes(Collection schemes) throws JAXRException { //Now we need to convert the collection into a vector for juddi BulkResponseImpl bulk = new BulkResponseImpl(); TModel[] entityarr = new TModel[schemes.size()]; LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); Collection<Exception> exceptions = new ArrayList<Exception>(); Iterator iter = schemes.iterator(); int currLoc = 0; while (iter.hasNext()) { try {/*from w ww . j a va 2 s. com*/ TModel en = ScoutJaxrUddiHelper .getTModelFromJAXRClassificationScheme((ClassificationScheme) iter.next()); entityarr[currLoc] = en; currLoc++; } catch (ClassCastException ce) { throw new UnexpectedObjectException(); } } log.debug("Method:save_classificationscheme: ENlength=" + entityarr.length); // Save business TModelDetail td = null; try { td = (TModelDetail) executeOperation(entityarr, "SAVE_TMODEL"); } catch (RegistryException e) { exceptions.add(new SaveException(e.getLocalizedMessage())); bulk.setStatus(JAXRResponse.STATUS_FAILURE); return bulk; } List<TModel> tmodelList = td.getTModel(); entityarr = new TModel[tmodelList.size()]; tmodelList.toArray(entityarr); log.debug("After Saving TModel. Obtained vector size:" + entityarr != null ? entityarr.length : 0); for (int i = 0; entityarr != null && i < entityarr.length; i++) { TModel tm = (TModel) entityarr[i]; coll.add(new KeyImpl(tm.getTModelKey())); } bulk.setCollection(coll); bulk.setExceptions(exceptions); return bulk; }
From source file:org.apache.ws.scout.registry.BusinessLifeCycleManagerV3Impl.java
public BulkResponse saveClassificationSchemes(Collection schemes) throws JAXRException { //Now we need to convert the collection into a vector for juddi BulkResponseImpl bulk = new BulkResponseImpl(); TModel[] entityarr = new TModel[schemes.size()]; LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); Collection<Exception> exceptions = new ArrayList<Exception>(); Iterator iter = schemes.iterator(); int currLoc = 0; while (iter.hasNext()) { try {//from w ww . j a v a 2s . c o m TModel en = ScoutJaxrUddiV3Helper .getTModelFromJAXRClassificationScheme((ClassificationScheme) iter.next()); entityarr[currLoc] = en; currLoc++; } catch (ClassCastException ce) { throw new UnexpectedObjectException(); } } log.debug("Method:save_classificationscheme: ENlength=" + entityarr.length); // Save business TModelDetail td = null; try { td = (TModelDetail) executeOperation(entityarr, "SAVE_TMODEL"); } catch (RegistryV3Exception e) { exceptions.add(new SaveException(e.getLocalizedMessage())); bulk.setStatus(JAXRResponse.STATUS_FAILURE); return bulk; } List<TModel> tmodelList = td.getTModel(); entityarr = new TModel[tmodelList.size()]; tmodelList.toArray(entityarr); log.debug("After Saving TModel. Obtained vector size:" + entityarr != null ? entityarr.length : 0); for (int i = 0; entityarr != null && i < entityarr.length; i++) { TModel tm = (TModel) entityarr[i]; coll.add(new KeyImpl(tm.getTModelKey())); } bulk.setCollection(coll); bulk.setExceptions(exceptions); return bulk; }
From source file:org.apache.ws.scout.registry.BusinessLifeCycleManagerV3Impl.java
public BulkResponse saveOrganizations(Collection organizations) throws JAXRException { //Now we need to convert the collection into a vector for juddi BulkResponseImpl bulk = new BulkResponseImpl(); BusinessEntity[] entityarr = new BusinessEntity[organizations.size()]; LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); Collection<Exception> exceptions = new ArrayList<Exception>(); Iterator iter = organizations.iterator(); int currLoc = 0; while (iter.hasNext()) { try {//from w w w. ja v a 2s . c o m BusinessEntity en = ScoutJaxrUddiV3Helper.getBusinessEntityFromJAXROrg((Organization) iter.next()); entityarr[currLoc] = en; currLoc++; } catch (ClassCastException ce) { throw new UnexpectedObjectException(); } } log.debug("Method:save_business: ENlength=" + entityarr.length); // Save business BusinessDetail bd = null; try { bd = (BusinessDetail) executeOperation(entityarr, "SAVE_ORG"); } catch (RegistryV3Exception e) { exceptions.add(new SaveException(e.getLocalizedMessage())); bulk.setStatus(JAXRResponse.STATUS_FAILURE); return bulk; } List<BusinessEntity> bizEntityList = bd.getBusinessEntity(); entityarr = new BusinessEntity[bizEntityList.size()]; bizEntityList.toArray(entityarr); log.debug("After Saving Business. Obtained vector size:" + entityarr != null ? entityarr.length : 0); for (int i = 0; entityarr != null && i < entityarr.length; i++) { BusinessEntity entity = (BusinessEntity) entityarr[i]; coll.add(new KeyImpl(entity.getBusinessKey())); } bulk.setCollection(coll); bulk.setExceptions(exceptions); return bulk; }
From source file:org.apache.ws.scout.registry.BusinessLifeCycleManagerImpl.java
public BulkResponse saveOrganizations(Collection organizations) throws JAXRException { //Now we need to convert the collection into a vector for juddi BulkResponseImpl bulk = new BulkResponseImpl(); BusinessEntity[] entityarr = new BusinessEntity[organizations.size()]; LinkedHashSet<Key> coll = new LinkedHashSet<Key>(); Collection<Exception> exceptions = new ArrayList<Exception>(); Iterator iter = organizations.iterator(); int currLoc = 0; while (iter.hasNext()) { try {/*from w w w.ja v a 2 s. co m*/ BusinessEntity en = ScoutJaxrUddiHelper.getBusinessEntityFromJAXROrg((Organization) iter.next()); entityarr[currLoc] = en; currLoc++; } catch (ClassCastException ce) { throw new UnexpectedObjectException(); } } log.debug("Method:save_business: ENlength=" + entityarr.length); // Save business BusinessDetail bd = null; try { bd = (BusinessDetail) executeOperation(entityarr, "SAVE_ORG"); } catch (RegistryException e) { exceptions.add(new SaveException(e.getLocalizedMessage())); bulk.setStatus(JAXRResponse.STATUS_FAILURE); bulk.setExceptions(exceptions); return bulk; } List<BusinessEntity> bizEntityList = bd.getBusinessEntity(); entityarr = new BusinessEntity[bizEntityList.size()]; bizEntityList.toArray(entityarr); log.debug("After Saving Business. Obtained vector size:" + entityarr != null ? entityarr.length : 0); for (int i = 0; entityarr != null && i < entityarr.length; i++) { BusinessEntity entity = (BusinessEntity) entityarr[i]; coll.add(new KeyImpl(entity.getBusinessKey())); } bulk.setCollection(coll); bulk.setExceptions(exceptions); return bulk; }
From source file:org.ala.dao.FulltextSearchDaoImplSolr.java
/** * Applies a prefix and suffix to higlight the search terms in the * supplied list./*from w ww .j a va 2 s . c o m*/ * * NC: This is a workaround as I can not get SOLR highlighting to work for partial term matches. * * @param names * @param m * @return */ private List<String> getHighlightedNames(List<String> names, java.util.regex.Matcher m, String prefix, String suffix) { LinkedHashSet<String> hlnames = null; List<String> lnames = null; if (names != null) { hlnames = new LinkedHashSet<String>(); for (String name : names) { String name1 = SolrUtils.concatName(name.trim()); m.reset(name1); if (m.find()) { //insert <b> and </b>at the start and end index name = name.substring(0, m.start()) + prefix + name.substring(m.start(), m.end()) + suffix + name.substring(m.end(), name.length()); hlnames.add(name); } } if (!hlnames.isEmpty()) { lnames = new ArrayList<String>(hlnames); Collections.sort(lnames); } else { lnames = new ArrayList<String>(); } } return lnames; }
From source file:org.codehaus.mojo.jsimport.AbstractImportMojo.java
/** * Process a file for import declarations and for the symbols used. * /*from w w w. ja v a2 s.com*/ * @param sourceFolder the base directory of the file being processed. * @param targetFolder where to write files to. * @param sourceFile the file to process. * @param fileDependencyGraphModificationTime the last time the dependency graph was updated or 0 if we do not have * one. * @param transitiveArtifacts any transititive artifacts to match imports against, or null if no matching is to be * done. * @return true if processing occurred. * @throws MojoExecutionException if something goes wrong. */ protected boolean processFileForImportsAndSymbols(File sourceFolder, File targetFolder, File sourceFile, long fileDependencyGraphModificationTime, Set<?> transitiveArtifacts) throws MojoExecutionException { URI sourceFileRelUri = sourceFolder.toURI().relativize(sourceFile.toURI()); File targetFile = new File(targetFolder, sourceFileRelUri.toString()); String sourceFilePath = sourceFile.getAbsolutePath(); // Quickly jump out if this particular artifact has not been updated // recently, or we don't have an entry for it in our dependency graph. The latter can happen if we build a multi // module project from the parent folder and then build a specific module from its own folder. File dependencies // in these scenarios can come from the module's target folder or the local m2 repo respectively. if (sourceFile.lastModified() <= fileDependencyGraphModificationTime && fileDependencies.containsKey(sourceFilePath)) { if (getLog().isDebugEnabled()) { getLog().debug("Skipping unchanged JS file: " + sourceFileRelUri); } return false; } if (getLog().isDebugEnabled()) { getLog().debug("Parsing JS file: " + sourceFileRelUri); } try { // Tokenise the JS file resulting in collections of assigned and // unassigned globals, and import statements. CharStream cs = new ANTLRFileStream(sourceFilePath); ECMAScriptLexer lexer = new ECMAScriptLexer(cs); lexer.setSourceFile(sourceFileRelUri, sourceFile.getName()); CommonTokenStream tokenStream = new CommonTokenStream(); tokenStream.setTokenSource(lexer); writeTokenStream(cs, tokenStream, targetFile); if (getLog().isDebugEnabled()) { getLog().debug("Assigned globals: " + lexer.getAssignedGlobalVars().toString()); getLog().debug("Unassigned globals: " + lexer.getUnassignedGlobalVars().toString()); getLog().debug("Imports: " + lexer.getImportGavs().toString()); } // For each assigned variable map it against the file we're dealing // with for later reference. An assigned variable indicates that // unassigned declarations of the same variable want this file // imported. for (String assignedGlobalVar : lexer.getAssignedGlobalVars()) { fileAssignedGlobals.put(assignedGlobalVar, sourceFilePath); } // For each unassigned variable map it against the file we're // dealing with for later reference. An unassigned variable // indicates that we want to import a file where the variable is // assigned. Set<String> vars = new HashSet<String>(lexer.getUnassignedGlobalVars()); if (assumeABrowser) { // If we assume a browser then take out all of the ones declared for it. Otherwise we'll be looking for // dependencies that do not belong to the project. vars.removeAll(Arrays.asList(new String[] { "clearInterval", "clearTimeout", "document", "exports", "event", "frames", "history", "Image", "location", "module", "name", "navigator", "Option", "parent", "require", "screen", "setInterval", "setTimeout", "window", "XMLHttpRequest" })); } fileUnassignedGlobals.put(sourceFilePath, vars); // For each import found resolve its file name and then note it as a // dependency of this particular js file. We update any existing // dependency edges if they exist given that we've determined this // part of the graph needs re-construction. LinkedHashSet<String> importedDependencies = new LinkedHashSet<String>(lexer.getImportGavs().size()); fileDependencies.put(sourceFilePath, importedDependencies); for (ECMAScriptLexer.GAV importGav : lexer.getImportGavs()) { Artifact artifactFound; Dependency dependencyFound = matchDirectDependency(importGav.groupId, importGav.artifactId); if (dependencyFound == null) { if (transitiveArtifacts != null) { artifactFound = matchTransitiveDependency(importGav.groupId, importGav.artifactId, transitiveArtifacts); } else { artifactFound = null; } if (artifactFound == null) { getLog().error("Dependency not found: " + importGav.groupId + ":" + importGav.artifactId); throw new MojoExecutionException("Build stopping given dependency issue."); } } else { artifactFound = resolveArtifact(dependencyFound); } /** * Store the dependency as an edge against our dependency graph. */ importedDependencies.add(artifactFound.getFile().getPath()); if (getLog().isDebugEnabled()) { getLog().debug("Found import: " + importGav.groupId + ":" + importGav.artifactId + " (" + artifactFound.getFile().getName() + ") for file: " + sourceFileRelUri); } } } catch (IOException e) { throw new MojoExecutionException("Problem opening file: " + sourceFileRelUri, e); } return true; }
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 {// w w w. j ava 2s . 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.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 {/* w w w .java2s. co 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); } }