List of usage examples for java.util Collection addAll
boolean addAll(Collection<? extends E> c);
From source file:admin.service.SimpleJobService.java
@Override public Collection<StepExecution> getStepExecutions(Long jobExecutionId) throws NoSuchJobExecutionException { JobExecution jobExecution = jobExecutionDao.getJobExecution(jobExecutionId); if (jobExecution == null) { throw new NoSuchJobExecutionException("No JobExecution with id=" + jobExecutionId); }/* ww w . ja v a 2s . c o m*/ stepExecutionDao.addStepExecutions(jobExecution); String jobName = jobExecution.getJobInstance() == null ? jobInstanceDao.getJobInstance(jobExecution).getJobName() : jobExecution.getJobInstance().getJobName(); Collection<String> missingStepNames = new LinkedHashSet<String>(); if (jobName != null) { missingStepNames.addAll(stepExecutionDao.findStepNamesForJobExecution(jobName, "*:partition*")); logger.debug("Found step executions in repository: " + missingStepNames); } Job job = null; try { job = jobLocator.getJob(jobName); } catch (NoSuchJobException e) { // expected } if (job instanceof StepLocator) { Collection<String> stepNames = ((StepLocator) job).getStepNames(); missingStepNames.addAll(stepNames); logger.debug("Added step executions from job: " + missingStepNames); } for (StepExecution stepExecution : jobExecution.getStepExecutions()) { String stepName = stepExecution.getStepName(); if (missingStepNames.contains(stepName)) { missingStepNames.remove(stepName); } logger.debug("Removed step executions from job execution: " + missingStepNames); } for (String stepName : missingStepNames) { StepExecution stepExecution = jobExecution.createStepExecution(stepName); stepExecution.setStatus(BatchStatus.UNKNOWN); } return jobExecution.getStepExecutions(); }
From source file:com.dragome.compiler.writer.Assembly.java
public int createAssembly() throws IOException { logger = Log.getLogger();/*from ww w .ja v a 2 s . c o m*/ logger.debug("Packing ..."); removeOldAssemblies(targetLocation); String loaderName = DragomeJsCompiler.compiler.getTargetPlatform().toLowerCase(); Writer writer; if ("javascript".equals(loaderName)) { writer = new FileWriter(targetLocation); pipeFileToStream(writer, "dragome/javascript/loaders/" + loaderName + ".js"); } else { targetLocation.mkdirs(); writer = new JunkWriter(targetLocation); } //writer.write("// Assembly generated by dragomeJs " + Utils.getVersion() + " on " + Utils.currentTimeStamp() + "\n"); writer.write("//***********************************************************************\n"); writer.write("//* Generated with Dragome SDK Copyright (c) 2011-2014 Fernando Petrola *\n"); writer.write("//***********************************************************************\n"); writer.write("\n"); // pipeFileToStream(writer, "javascript/q-3.0.js"); pipeFileToStream(writer, "dragome/javascript/runtime.js"); // writer.write("dragomeJs.assemblyVersion = 'dragomeJs Assembly " + targetLocation.getName() + "@" + Utils.currentTimeStamp() + "';\n"); writer.write("dragomeJs.userData = {};\n"); // int classCount= 0; // for (ClassUnit fileUnit : project.getClasses()) // { // if (!fileUnit.isTainted()) // continue; // writer.write("dragomeJs."); // writer.write(DECLARECLASS); // writer.write("(\"" + fileUnit.getSignature() + "\""); // writer.write(", " + fileUnit.getSignature().getId()); // writer.write(");\n"); // classCount++; // } project.currentGeneratedMethods = 0; if (DragomeJsCompiler.compiler.getSingleEntryPoint() != null) { Signature signature = project.getSignature(DragomeJsCompiler.compiler.getSingleEntryPoint()); ClassUnit clazz = project.getClassUnit(signature.className()); clazz.write(0, writer); } else { ClassUnit object = project.getJavaLangObject(); object.write(0, writer); do { ClassUnit.oneWritten = false; for (ClassUnit cu : project.getClasses()) { // if (cu.isInterface) { cu.write(0, writer); } } } while (ClassUnit.oneWritten); } ClassUnit stringClazz = project.getClassUnit(String.class.getName()); ClassUnit stringSuperClazz = stringClazz.getSuperUnit(); Collection<MemberUnit> declaredMembers = new ArrayList<MemberUnit>(stringClazz.getDeclaredMembers()); declaredMembers.addAll(stringSuperClazz.getDeclaredMembers()); for (MemberUnit memberUnit : declaredMembers) { Signature signature = memberUnit.getSignature(); String normalizeExpression = DragomeJavaScriptGenerator.normalizeExpression(signature); writer.write("String.prototype." + normalizeExpression + "= java_lang_String.prototype." + normalizeExpression + ";\n"); } writer.write("String.prototype.classname= \"java_lang_String\";\n"); for (MemberUnit member : ClassUnit.stringInits) { String memberData = member.getData(); member.setData(member.getData().substring(1)); member.write(1, writer); member.setData(memberData); if (member instanceof ProcedureUnit) { project.currentGeneratedMethods++; writer.flush(); } } // project.writeClinits(writer); if (getProject().getOrCreateClassUnit("java.lang.String").isTainted()) { writer.write("String.prototype.clazz = java_lang_String;\n"); } // writer.write("dragomeJs.onLoad('" + entryPointClassName + "#main(java.lang.String[])void');\n"); writer.write("javascript_Utils.$init$void();\n"); project.writeSignatures(writer); writer.write( "java_lang_Object.prototype.toString= function (){return this.$toString$java_lang_String();};\n"); //TODO mover despues de creacion de Object // writer.write("Array.prototype.$clone$java_lang_Object= java_lang_Object.prototype.$clone$java_lang_Object;\n"); //TODO mover despues de creacion de Object writeAnnotationsInsertion(writer); // writer.write("new " + mainClass + "();\n"); // writer.write(mainClass + "." + mainMethod + "();\n"); writer.write("$(function(){setupCheckCast(); _ed.executeMainClass();});"); writer.close(); return project.currentGeneratedMethods; }
From source file:grails.plugin.cache.GrailsAnnotationCacheOperationSource.java
/** * Determine the cache operation(s) for the given method or class. * <p>This implementation delegates to configured * {@link CacheAnnotationParser}s for parsing known annotations into * Spring's metadata attribute class.//www. j a va 2 s .co m * <p>Can be overridden to support custom annotations that carry * caching metadata. * @param ae the annotated method or class * @return the configured caching operations, or {@code null} if none found */ protected Collection<CacheOperation> determineCacheOperations(AnnotatedElement ae) { Collection<CacheOperation> ops = null; for (CacheAnnotationParser annotationParser : annotationParsers) { Collection<CacheOperation> annOps = annotationParser.parseCacheAnnotations(ae); if (annOps != null) { if (ops == null) { ops = new ArrayList<CacheOperation>(); } ops.addAll(annOps); } } return ops; }
From source file:com.adaptris.core.SharedComponentList.java
private Collection<AdaptrisComponent> all() { Collection<AdaptrisComponent> comps = new IgnoreNulls<AdaptrisComponent>(); comps.addAll(getServices()); comps.addAll(getConnections());// www .j a va 2 s .co m comps.add(getTransactionManager()); return comps; }
From source file:myfightinglayoutbugs.FightingLayoutBugs.java
/** * Runs all registered {@link LayoutBugDetector}s. Before you call this method, you might:<ul> * <li>register new detectors via {@link #enable},</li> * <li>remove unwanted detectors via {@link #disable},</li> * <li>configure a registered detector via {@link #configure},</li> * <li>configure the {@link TextDetector} to be used via {@link #setTextDetector},</li> * <li>configure the {@link EdgeDetector} to be used via {@link #setEdgeDetector}.</li> * </ul>// www.j ava 2 s.co m */ public Collection<LayoutBug> findLayoutBugsIn(@Nonnull WebPage webPage) { if (webPage == null) { throw new IllegalArgumentException("Method parameter webPage must not be null."); } if (_debugMode) { setLogLevelToDebug(); registerDebugListener(); } try { TextDetector textDetector = (_textDetector == null ? new AnimationAwareTextDetector() : _textDetector); EdgeDetector edgeDetector = (_edgeDetector == null ? new SimpleEdgeDetector() : _edgeDetector); try { LOG.debug("Analyzing " + webPage.getUrl() + " ..."); webPage.setTextDetector(textDetector); webPage.setEdgeDetector(edgeDetector); final Collection<LayoutBug> result = new ArrayList<LayoutBug>(); for (LayoutBugDetector detector : _detectors) { detector.setScreenshotDir(screenshotDir); LOG.debug("Running " + detector.getClass().getSimpleName() + " ..."); result.addAll(detector.findLayoutBugsIn(webPage)); } // TODO: If layout bugs have been detected, LOG.info(diagnostic info + further instrcutions) return result; } catch (RuntimeException e) { String url = null; try { url = webPage.getUrl().toString(); } catch (Exception ignored) { } StringBuilder sb = new StringBuilder(); sb.append("Failed to analyze ").append(url == null ? "given WebPage" : url).append(" -- ") .append(e.toString()).append("\n"); if (_debugMode) { sb.append( "If you want support (or want to support FLB) you can send an email to fighting-layout-bugs@googlegroups.com with the following information:\n"); sb.append(" - Your code.\n"); sb.append(" - All logged output.\n"); sb.append(" - All screenshot files (you might want to pack those into an zip archive).\n"); sb.append("TextDetector: ").append(textDetector.getClass().getName()).append("\n"); sb.append("EdgeDetector: ").append(edgeDetector.getClass().getName()).append("\n"); sb.append(DebugHelper.getDiagnosticInfo(webPage.getDriver())); // TODO: We should create the zip file here ourselves. } else { sb.append( "If you call FightingLayoutBugs.enableDebugMode() before you call FightingLayoutBugs.findLayoutBugsIn(...) you can get more information."); } String errorMessage = sb.toString(); LOG.error(errorMessage); throw new RuntimeException(errorMessage, e); } } finally { for (Runnable runnable : _runAfterAnalysis) { try { runnable.run(); } catch (RuntimeException e) { LOG.warn(runnable + " failed.", e); } } } }
From source file:com.bluexml.side.Framework.alfresco.dataGenerator.dictionary.AlfrescoModelDictionary.java
/** * /* ww w. ja v a 2s .c o m*/ * @param types * @param qNameModel * @return properties by type defined in the loaded model */ private Map<TypeDefinition, Collection<PropertyDefinition>> getProperties(Collection<TypeDefinition> types, QName qNameModel) { Map<TypeDefinition, Collection<PropertyDefinition>> properties = new HashMap<TypeDefinition, Collection<PropertyDefinition>>(); for (TypeDefinition typeDefinition : ((AlfrescoModelStructure) alfrescoModelStructure).getTypes()) { Collection<PropertyDefinition> propertiesByType = getProperties(typeDefinition); QName qnamedParent = typeDefinition.getParentName(); while (qnamedParent != null) { TypeDefinition parentType = dictionaryService.getType(qnamedParent); propertiesByType.addAll(getProperties(parentType)); qnamedParent = parentType.getParentName(); } properties.put(typeDefinition, propertiesByType); } return properties; }
From source file:com.anhth12.lambda.app.serving.als.model.ALSServingModel.java
public Collection<String> getAllItemIDs() { Collection<String> itemsList = new ArrayList<>(); for (int partition = 0; partition < Y.length; partition++) { try (AutoLock al = new AutoLock(yLocks[partition].readLock())) { itemsList.addAll(Y[partition].keySet()); }//from w ww . java2 s. co m } return itemsList; }
From source file:co.turnus.analysis.bottlenecks.util.HotspotsDataAnalyser.java
@SuppressWarnings("unchecked") public <T> Map<T, ExtendExecData> getSumDataMap(Class<T> type, Key key, Order order) { Map<T, ExtendExecData> tmpMap = Maps.newHashMap(); List<Map.Entry<T, ExtendExecData>> list = new ArrayList<>(); if (type.isAssignableFrom(Actor.class)) { for (Actor actor : network.getActors()) { tmpMap.put((T) actor, getSumData(actor)); }// ww w . java 2 s. co m list.addAll(tmpMap.entrySet()); } else if (type.isAssignableFrom(ActorClass.class)) { for (ActorClass clazz : network.getActorClasses()) { tmpMap.put((T) clazz, getSumData(clazz)); } list.addAll(tmpMap.entrySet()); } else if (type.isAssignableFrom(Action.class)) { Collection<Action> actions = Sets.newHashSet(); for (ActorClass clazz : network.getActorClasses()) { actions.addAll(clazz.getActions()); } for (Action action : actions) { tmpMap.put((T) action, getSumData(action)); } list.addAll(tmpMap.entrySet()); } else { return null; } mapComparator.setSorting(key, order); Collections.sort(list, mapComparator); Map<T, ExtendExecData> data = new LinkedMap(); for (Entry<T, ExtendExecData> entry : list) { data.put(entry.getKey(), entry.getValue()); } return data; }
From source file:com.salesmanager.catalog.category.CategoryListAction.java
private void setCategories(Category c, int startIndex) throws Exception { MerchantStore store = SessionUtil.getMerchantStore(super.getServletRequest()); CacheModule cache = (CacheModule) SpringUtil.getBean("cache"); CatalogService cservice = (CatalogService) ServiceFactory.getService(ServiceFactory.CatalogService); // get store template maximum item quantity per page List idList = new ArrayList(); // Get category list for left menu String lineageQuery = new StringBuffer().append(c.getLineage()).append(c.getCategoryId()) .append(CatalogConstants.LINEAGE_DELIMITER).toString(); this.setCategoryLineage(lineageQuery); // Category List from cache CategoryList categoryList = null;/*from www . ja va 2 s . c om*/ try { categoryList = (CategoryList) cache.getFromCache( Constants.CACHE_CATEGORIES + lineageQuery + "_" + super.getLocale().getLanguage(), store); } catch (Exception ignore) { } if (categoryList == null) { // get from missed boolean missed = false; try { missed = (Boolean) cache.getFromCache( Constants.CACHE_CATEGORIES + lineageQuery + "_MISSED_" + super.getLocale().getLanguage(), store); } catch (Exception ignore) { } if (!missed) { Collection subcategs = cservice.findCategoriesByMerchantIdAndLineageAndLanguageId(c.getMerchantId(), lineageQuery, super.getLocale().getLanguage()); Collection ids = new ArrayList(); if (subcategs != null && subcategs.size() > 0) { categoryList = new CategoryList(); Iterator cIterator = subcategs.iterator(); while (cIterator.hasNext()) { Category sc = (Category) cIterator.next(); categories.add(sc); idList.add(sc.getCategoryId()); } Collection categs = new ArrayList(); categs.addAll(categories); categoryList.setCategories(categs); } // add master category idList.add(c.getCategoryId()); if (subcategs != null && subcategs.size() > 0) { ids.addAll(idList); categoryList.setCategoryIds(ids); } if (categoryList != null) { try { cache.putInCache( Constants.CACHE_CATEGORIES + lineageQuery + "_" + super.getLocale().getLanguage(), categoryList, Constants.CACHE_CATEGORIES, store); } catch (Exception e) { logger.error(e); } } else { try { cache.putInCache( Constants.CACHE_CATEGORIES + lineageQuery + "_MISSED_" + super.getLocale().getLanguage(), categoryList, Constants.CACHE_CATEGORIES, store); } catch (Exception e) { logger.error(e); } } } } else { idList.add(c.getCategoryId()); idList.addAll(categoryList.getCategoryIds()); } int productCount = getProductCount(); // get product list SearchProductCriteria criteria = new SearchProductCriteria(); criteria.setMerchantId(store.getMerchantId()); criteria.setCategoryList(idList); criteria.setLanguageId(LanguageUtil.getLanguageNumberCode(super.getLocale().getLanguage())); criteria.setQuantity(productCount);// qty based on template config criteria.setStartindex(startIndex); SearchProductResponse response = cservice.findProductsByCategoryList(criteria); this.setListingCount(response.getCount()); Collection prds = response.getProducts(); LocaleUtil.setLocaleToEntityCollection(prds, super.getLocale(), store.getCurrency()); // get category path try { categoryPath = (Collection) cache.getFromCache( Constants.CACHE_CATEGORIES_PATH + "_" + c.getCategoryId() + "_" + super.getLocale(), store); } catch (Exception ignore) { } if (categoryPath == null || categoryPath.size() == 0) { // get from missed boolean missed = false; try { missed = (Boolean) cache.getFromCache( Constants.CACHE_CATEGORIES_PATH + "_MISSED_" + c.getCategoryId() + "_" + super.getLocale(), store); } catch (Exception ignore) { } if (!missed) { categoryPath = CategoryUtil.getCategoryPath(super.getLocale().getLanguage(), store.getMerchantId(), c.getCategoryId()); if (categoryPath != null && categoryPath.size() > 0) { try { cache.putInCache( Constants.CACHE_CATEGORIES_PATH + "_" + c.getCategoryId() + "_" + super.getLocale(), categoryPath, Constants.CACHE_CATEGORIES, store); } catch (Exception e) { logger.error(e); } } else { try { cache.putInCache(Constants.CACHE_CATEGORIES_PATH + "_MISSED_" + c.getCategoryId() + "_" + super.getLocale(), true, Constants.CACHE_CATEGORIES, store); } catch (Exception e) { logger.error(e); } } } } categoryPath = CategoryUtil.getCategoryPath(super.getLocale().getLanguage(), store.getMerchantId(), c.getCategoryId()); products = prds; super.setListingCount(response.getCount()); super.setRealCount(products.size()); super.setPageElements(); /* * if(products==null || products.size()==0) { this.setFirstItem(0); * this.setLastItem(response.getCount()); } else { * * this.setFirstItem(startIndex+1); if(productCount<response.getCount()) * { this.setLastItem(startIndex + products.size()); } else { * this.setLastItem(response.getCount()); } } */ }
From source file:org.nabucco.alfresco.enhScriptEnv.common.script.functions.AbstractLogFunction.java
protected Collection<Logger> getLoggers(final Object scope, final ReferenceScript referenceScript, final LoggerData loggerData) { final Collection<Logger> loggers; if (loggerData == null || loggerData.getLoggers() == null) { loggers = new HashSet<Logger>(); if (referenceScript != null) { loggers.addAll(this.getParentLoggers(scope, referenceScript)); }//w w w . j a v a2s . c o m if (loggerData != null && loggerData.getExplicitLogger() != null) { loggers.add(LoggerFactory.getLogger(loggerData.getExplicitLogger())); } else if (!this.isParentLoggerExplicit(scope, referenceScript)) { // Note: We previously included the legacy script logger explicitly here, but this is now handled separately if (referenceScript != null) { final Collection<ReferencePathType> supportedReferencePathTypes = referenceScript .getSupportedReferencePathTypes(); for (final ReferencePathType referencePathType : supportedReferencePathTypes) { final String referencePath = referenceScript.getReferencePath(referencePathType); if (referencePath != null) { final String loggerSuffix = referencePath.replace('.', '_').replace('/', '.'); final String loggerName = MessageFormat.format("{0}.{1}.{2}", this.defaultLoggerPrefix, referencePathType, loggerSuffix); loggers.add(LoggerFactory.getLogger(loggerName)); } } } } if (loggerData != null) { loggerData.setLoggers(loggers); } } else { loggers = loggerData.getLoggers(); } return loggers; }