List of usage examples for java.util Queue addAll
boolean addAll(Collection<? extends E> c);
From source file:com.tasktop.c2c.server.internal.tasks.domain.conversion.TaskConverter.java
@SuppressWarnings("unchecked") @Override//ww w . ja v a 2 s .c o m public void copy(Task target, Object internalObject, DomainConverter converter, DomainConversionContext context) { com.tasktop.c2c.server.internal.tasks.domain.Task source = (com.tasktop.c2c.server.internal.tasks.domain.Task) internalObject; DomainConversionContext subcontext = context.subcontext(); target.setId(source.getId()); target.setFoundInRelease( source.getVersion() == null ? null : source.getVersion().isEmpty() ? null : source.getVersion()); target.setCreationDate(source.getCreationTs()); target.setModificationDate(source.getDeltaTs()); target.setVersion(source.getDeltaTs() == null ? null : Long.toString(source.getDeltaTs().getTime())); target.setShortDescription(source.getShortDesc()); target.setEstimatedTime(source.getEstimatedTime()); target.setRemainingTime(source.getRemainingTime()); target.setDeadline(source.getDeadline()); target.setUrl(configuration.getWebUrlForTask(target.getId())); // Mandatory custom fields target.setTaskType(source.getTaskType()); List<ExternalTaskRelation> externalTaskRelations = new ArrayList<ExternalTaskRelation>(); if (source.getExternalTaskRelations() != null) { String[] strings = StringUtils.split(source.getExternalTaskRelations(), "\n"); Pattern p = Pattern.compile("(.*)\\.(.*): (.*)"); for (String string : strings) { Matcher matcher = p.matcher(string); if (matcher.matches()) { String type = matcher.group(1); String kind = matcher.group(2); String uri = matcher.group(3); externalTaskRelations.add(new ExternalTaskRelation(type, kind, uri)); } } } target.setExternalTaskRelations(externalTaskRelations); List<String> commits = new ArrayList<String>(); if (source.getCommits() != null) { for (String commit : StringUtils.split(source.getCommits(), ",")) { commits.add(commit); } } target.setCommits(commits); // These must be set from query join results target.setSeverity(context.getTaskSeverity(source.getSeverity())); target.setStatus(context.getTaskStatus(source.getStatus())); target.setResolution(context.getTaskResolution(source.getResolution())); target.setPriority(context.getPriority(source.getPriority())); target.setMilestone(context.getMilestone(source.getProduct(), source.getTargetMilestone())); target.setProduct((Product) converter.convert(source.getProduct(), subcontext)); target.setComponent((Component) converter.convert(source.getComponent(), subcontext)); target.setReporter((TaskUserProfile) converter.convert(source.getReporter(), subcontext)); target.setAssignee((TaskUserProfile) converter.convert(source.getAssignee(), subcontext)); target.setWatchers((List<TaskUserProfile>) converter.convert(source.getCcs(), subcontext)); List<Keyworddef> keyworddefs = new ArrayList<Keyworddef>(); for (com.tasktop.c2c.server.internal.tasks.domain.Keyword keyword : source.getKeywordses()) { keyworddefs.add(keyword.getKeyworddefs()); } target.setKeywords((List<Keyword>) converter.convert(keyworddefs, subcontext)); // Description (first comment), Comments, and Worklog items (comment with workTime) copyCommentsAndWorkLogs(target, source.getComments(), converter, context); BigDecimal sumOfSubtasksEstimate = BigDecimal.ZERO; BigDecimal sumOfSubtasksTimeSpent = BigDecimal.ZERO; Queue<Dependency> subTaskQueue = new LinkedList<Dependency>(source.getDependenciesesForBlocked()); while (!subTaskQueue.isEmpty()) { com.tasktop.c2c.server.internal.tasks.domain.Task subTask = subTaskQueue.poll().getBugsByDependson(); subTaskQueue.addAll(subTask.getDependenciesesForBlocked()); if (subTask.getEstimatedTime() != null) { sumOfSubtasksEstimate = sumOfSubtasksEstimate.add(subTask.getEstimatedTime()); } for (com.tasktop.c2c.server.internal.tasks.domain.Comment c : subTask.getComments()) { if (c.getWorkTime() != null && c.getWorkTime().signum() > 0) { sumOfSubtasksTimeSpent = sumOfSubtasksTimeSpent.add(c.getWorkTime()); } } } target.setSumOfSubtasksEstimatedTime(sumOfSubtasksEstimate); target.setSumOfSubtasksTimeSpent(sumOfSubtasksTimeSpent); if (!context.isThin()) { target.setBlocksTasks(new ArrayList<Task>(source.getDependenciesesForDependson().size())); for (Dependency dep : source.getDependenciesesForDependson()) { target.getBlocksTasks().add(shallowCopyAssociate(dep.getBugsByBlocked(), subcontext)); } target.setSubTasks(new ArrayList<Task>(source.getDependenciesesForBlocked().size())); for (Dependency dep : source.getDependenciesesForBlocked()) { target.getSubTasks().add(shallowCopyAssociate(dep.getBugsByDependson(), subcontext)); } if (source.getDuplicatesByBugId() != null) { target.setDuplicateOf( shallowCopyAssociate(source.getDuplicatesByBugId().getBugsByDupeOf(), subcontext)); } target.setDuplicates(new ArrayList<Task>()); for (Duplicate duplicate : source.getDuplicatesesForDupeOf()) { target.getDuplicates().add(shallowCopyAssociate(duplicate.getBugsByBugId(), subcontext)); } if (source.getStatusWhiteboard() != null && !source.getStatusWhiteboard().isEmpty()) { // A non-empty statusWhiteboard means we store description there for backward compatibility. (See // discussion in Task 422) target.setDescription(source.getStatusWhiteboard()); // REVIEW do we really need this for subtasks? target.setWikiRenderedDescription( renderer.render(source.getStatusWhiteboard(), context.getWikiMarkup())); } target.setAttachments((List<Attachment>) converter.convert(source.getAttachments(), subcontext)); } else { // THIN tasks still get their parent populated if (!source.getDependenciesesForDependson().isEmpty()) { target.setParentTask(shallowCopyAssociate( source.getDependenciesesForDependson().get(0).getBugsByBlocked(), subcontext)); } } }
From source file:org.primeframework.mvc.util.ClassClasspathResolver.java
private Collection<Class<U>> loadFromDirectory(File dir, Test<Class<U>> test, boolean recursive) throws IOException { Set<Class<U>> matches = new HashSet<Class<U>>(); // Loop over the files Queue<File> files = new LinkedList<File>(safeListFiles(dir, null)); while (!files.isEmpty()) { File file = files.poll(); if (file.isDirectory() && recursive) { files.addAll(safeListFiles(file, null)); } else if (file.isFile()) { // This file matches, test it Testable<Class<U>> testable = test.prepare(file); if (testable != null && testable.passes()) { matches.add(testable.result()); }/*w w w . j av a 2s . com*/ } } return matches; }
From source file:org.opencron.server.service.ExecuteService.java
/** * ? ???/* ww w.ja v a 2s .co m*/ */ private boolean executeFlowJob(JobVo job) { if (!checkJobPermission(job.getAgentId(), job.getUserId())) return false; final long groupId = System.nanoTime() + Math.abs(new Random().nextInt());//??Id final Queue<JobVo> jobQueue = new LinkedBlockingQueue<JobVo>(); jobQueue.add(job); jobQueue.addAll(job.getChildren()); RunModel runModel = RunModel.getRunModel(job.getRunModel()); switch (runModel) { case SEQUENCE: return executeSequenceJob(groupId, jobQueue);// case SAMETIME: return executeSameTimeJob(groupId, jobQueue);// default: return false; } }
From source file:org.kuali.rice.krad.uif.util.ComponentUtils.java
/** * Get all nested children of a given component. * * @param component The component to search. * @return All nested children of the component. * @see ViewLifecycleUtils#getElementsForLifecycle(LifecycleElement) *///w ww.j av a 2s .com public static List<Component> getAllNestedComponents(Component component) { if (component == null) { return Collections.emptyList(); } List<Component> components = Collections.emptyList(); @SuppressWarnings("unchecked") Queue<LifecycleElement> elementQueue = RecycleUtils.getInstance(LinkedList.class); elementQueue.offer(component); try { while (!elementQueue.isEmpty()) { LifecycleElement currentElement = elementQueue.poll(); if (currentElement == null) { continue; } if (currentElement instanceof Component && currentElement != component) { if (components.isEmpty()) { components = new ArrayList<Component>(); } components.add((Component) currentElement); } elementQueue.addAll(ViewLifecycleUtils.getElementsForLifecycle(currentElement).values()); } } finally { elementQueue.clear(); RecycleUtils.recycle(elementQueue); } return components; }
From source file:org.kuali.rice.krad.uif.util.ComponentUtils.java
public static void prefixBindingPathNested(Component component, String addBindingPrefix) { @SuppressWarnings("unchecked") Queue<LifecycleElement> elementQueue = RecycleUtils.getInstance(LinkedList.class); elementQueue.offer(component);/*from w w w .ja v a2 s. co m*/ try { while (!elementQueue.isEmpty()) { LifecycleElement currentElement = elementQueue.poll(); if (currentElement == null) { continue; } if (currentElement instanceof DataBinding) { if (LOG.isDebugEnabled()) { LOG.info("setting nested binding prefix '" + addBindingPrefix + "' on " + currentElement); } prefixBindingPath((DataBinding) currentElement, addBindingPrefix); } elementQueue.addAll(ViewLifecycleUtils.getElementsForLifecycle(currentElement).values()); } } finally { elementQueue.clear(); RecycleUtils.recycle(elementQueue); } }
From source file:edu.pitt.dbmi.deep.phe.i2b2.I2b2OntologyBuilder.java
private TreeSet<PartialPath> extractOntologyPartialPaths() throws OWLOntologyCreationException, IOException { final TreeSet<PartialPath> partialPaths = new TreeSet<PartialPath>(); OWLOntologyManager m = OWLManager.createOWLOntologyManager(); // OWLOntology o = m.loadOntologyFromOntologyDocument(pizza_iri); OWLOntology o = loadDeepPheOntology(m); OWLReasonerFactory reasonerFactory;/*from w w w .ja v a2s . c o m*/ reasonerFactory = new StructuralReasonerFactory(); OWLReasoner reasoner = reasonerFactory.createReasoner(o); OWLDataFactory fac = m.getOWLDataFactory(); OWLClass elementConcept = fac.getOWLClass(IRI.create(CONST_TOP_LEVEL_ENTRY)); final Queue<PartialPath> partialPathQueue = new LinkedList<PartialPath>(); NodeSet<OWLClass> subClses = reasoner.getSubClasses(elementConcept, true); for (Node<OWLClass> subCls : subClses) { PartialPath path = new PartialPath(); path.setReasoner(reasoner); path.setCls(subCls.getRepresentativeElement()); path.setLevel(1); partialPathQueue.add(path); } while (true) { PartialPath path; path = partialPathQueue.poll(); if (path == null) { break; } else { partialPathQueue.addAll(path.expand()); } partialPaths.add(path); } PartialPath topLevel = new PartialPath(); topLevel.setPath("\\DEEPPHE"); topLevel.setLevel(0); topLevel.setLeaf(false); partialPaths.add(topLevel); return partialPaths; }
From source file:org.primeframework.mvc.util.ClassClasspathResolver.java
private Set<File> findDirectories(File dir, String locator) { // Loop over the files using tail-recursion Set<File> directories = new HashSet<File>(); Queue<File> files = new LinkedList<File>(safeListFiles(dir, DirectoryFileFilter.INSTANCE)); while (!files.isEmpty()) { File file = files.poll(); if (file.isDirectory() && file.getName().equals(locator)) { directories.add(file);//from ww w . jav a 2 s . c o m } else if (file.isDirectory()) { files.addAll(safeListFiles(file, null)); } } return directories; }
From source file:de.tbuchloh.kiskis.gui.treeview.TreeView.java
/** * @return gets all the displayed tree nodes *///ww w . j a v a 2 s. c o m protected Collection<MyTreeNode> getAllNodes() { final Queue<MyTreeNode> treeNodes = new LinkedList<MyTreeNode>(); treeNodes.add(getRoot()); final Collection<MyTreeNode> r = new LinkedList<MyTreeNode>(); r.add(getRoot()); while (!treeNodes.isEmpty()) { final MyTreeNode node = treeNodes.poll(); final List<MyTreeNode> children = Collections.list(node.children()); treeNodes.addAll(children); r.addAll(children); } return r; }
From source file:org.opencron.server.service.ExecuteService.java
/** * // w w w . j a v a2 s . com */ public boolean killJob(Record record) { final Queue<Record> recordQueue = new LinkedBlockingQueue<Record>(); //? if (JobType.SINGLETON.getCode().equals(record.getJobType())) { recordQueue.add(record); } else if (JobType.FLOW.getCode().equals(record.getJobType())) { //? recordQueue.addAll(recordService.getRunningFlowJob(record.getRecordId())); } final List<Boolean> result = new ArrayList<Boolean>(0); Thread jobThread = new Thread(new Runnable() { @Override public void run() { for (final Record cord : recordQueue) { //kill(?,?kill) Thread thread = new Thread(new Runnable() { public void run() { //??... cord.setStatus(RunStatus.STOPPING.getStatus());//? cord.setSuccess(ResultStatus.KILLED.getStatus());//?. JobVo job = null; try { recordService.save(cord); job = jobService.getJobVoById(cord.getJobId()); //???kill opencronCaller.call( Request.request(job.getIp(), job.getPort(), Action.KILL, job.getPassword()) .putParam("pid", cord.getPid()), job.getAgent()); cord.setStatus(RunStatus.STOPED.getStatus()); cord.setEndTime(new Date()); recordService.save(cord); loggerInfo("killed successful :jobName:{} at ip:{},port:{},pid:{}", job, cord.getPid()); } catch (Exception e) { if (e instanceof PacketTooBigException) { noticeService.notice(job, PACKETTOOBIG_ERROR); loggerError("killed error:jobName:%s at ip:%s,port:%d,pid:%s", job, cord.getPid() + " failed info: " + PACKETTOOBIG_ERROR, e); } noticeService.notice(job, null); loggerError("killed error:jobName:%s at ip:%s,port:%d,pid:%s", job, cord.getPid() + " failed info: " + e.getMessage(), e); result.add(false); } } }); thread.start(); } } }); jobThread.start(); //?kill,kill?... try { jobThread.join(); } catch (InterruptedException e) { logger.error("[opencron] kill job with error:{}", e.getMessage()); } return !result.contains(false); }
From source file:org.orekit.models.earth.tessellation.EllipsoidTessellator.java
/** Expand a mesh so it surrounds at least one connected part of a zone. * <p>// ww w . j a v a2 s . co m * This part of mesh expansion is neighbors based. It includes the seed * node neighbors, and their neighbors, and the neighbors of their * neighbors until the path-connected sub-parts of the zone these nodes * belong to are completely surrounded by the mesh taxicab boundary. * </p> * @param mesh mesh to expand * @param seeds seed nodes (already in the mesh) from which to start expansion * @param zone zone to mesh * @exception OrekitException if tile direction cannot be computed */ private void neighborExpandMesh(final Mesh mesh, final Collection<Mesh.Node> seeds, final SphericalPolygonsSet zone) throws OrekitException { // mesh expansion loop boolean expanding = true; final Queue<Mesh.Node> newNodes = new LinkedList<Mesh.Node>(); newNodes.addAll(seeds); while (expanding) { // first expansion step: set up the mesh so that all its // inside nodes are completely surrounded by at least // one layer of outside nodes while (!newNodes.isEmpty()) { // retrieve an active node final Mesh.Node node = newNodes.remove(); if (node.isInside()) { // the node is inside the zone, the mesh must contain its 8 neighbors addAllNeighborsIfNeeded(node, mesh, newNodes); } } // second expansion step: check if the loop of outside nodes // completely surrounds the zone, i.e. there are no peaks // pointing out of the loop between two nodes expanding = false; final List<Mesh.Node> boundary = mesh.getTaxicabBoundary(false); if (boundary.size() > 1) { Mesh.Node previous = boundary.get(boundary.size() - 1); for (final Mesh.Node node : boundary) { if (meetInside(previous.getS2P(), node.getS2P(), zone)) { // part of the mesh boundary is still inside the zone! // the mesh must be expanded again addAllNeighborsIfNeeded(previous, mesh, newNodes); addAllNeighborsIfNeeded(node, mesh, newNodes); expanding = true; } previous = node; } } } }