List of usage examples for java.util HashSet contains
public boolean contains(Object o)
From source file:net.countercraft.movecraft.async.translation.TranslationTask.java
private boolean isFreeSpace(int x, int y, int z, MovecraftLocation[] blocksList, HashSet<MovecraftLocation> existingBlockSet, boolean waterCraft, boolean hoverCraft, List<Material> harvestBlocks, boolean canHoverOverWater, boolean checkHover) { boolean isFree = true; // this checking for hovercrafts should be faster with separating horizontal layers and checking only realy necesseries, // or more better: remember what checked in each translation, but it's beyond my current abilities, I will try to solve it in future for (MovecraftLocation oldLoc : blocksList) { MovecraftLocation newLoc = oldLoc.translate(x, y, z); Material testMaterial = getCraft().getW().getBlockAt(newLoc.getX(), newLoc.getY(), newLoc.getZ()) .getType();//from www. j a va2s. c om if (!canHoverOverWater) { if (testMaterial.equals(Material.STATIONARY_WATER) || testMaterial.equals(Material.WATER)) { fail(String.format( I18nSupport.getInternationalisedString("Translation - Failed Craft over water"))); } } if (newLoc.getY() >= data.getMaxHeight() && newLoc.getY() > oldLoc.getY() && !checkHover) { //if ( newLoc.getY() >= data.getMaxHeight() && newLoc.getY() > oldLoc.getY()) { isFree = false; break; } else if (newLoc.getY() <= data.getMinHeight() && newLoc.getY() < oldLoc.getY()) { isFree = false; break; } boolean blockObstructed; if (!waterCraft) { // New block is not air or a piston head and is not part of the existing ship blockObstructed = (!testMaterial.equals(Material.AIR)) && !existingBlockSet.contains(newLoc); } else { // New block is not air or water or a piston head and is not part of the existing ship blockObstructed = (!testMaterial.equals(Material.AIR) && !testMaterial.equals(Material.STATIONARY_WATER) && !testMaterial.equals(Material.WATER)) && !existingBlockSet.contains(newLoc); } if (blockObstructed && hoverCraft) { // New block is not harvested block and is not part of the existing craft if (harvestBlocks.contains(testMaterial) && !existingBlockSet.contains(newLoc)) { blockObstructed = false; } else { blockObstructed = true; } } if (blockObstructed) { isFree = false; break; } } return isFree; }
From source file:dao.DirectoryAuthorDaoDb.java
/** * This methods lists all users //from w w w. ja v a2 s. c om * @param directoryId - directoryId * @param userId - userId * @param userLogin - userLogin * @param accessFlag the acess flag to read slave(0) or master (1) * @return List - list of all users alphabets (first,last,login) * @throws BaseDaoException */ public List getAllUsersAlphabet(String directoryId, String userId, String userLogin, int accessFlag) throws BaseDaoException { if (RegexStrUtil.isNull(userLogin) || RegexStrUtil.isNull(userId) || RegexStrUtil.isNull(directoryId)) { throw new BaseDaoException("params are null"); } /** * check user permissions */ if (!diaryAdmin.isDiaryAdmin(userLogin) && !isAuthor(directoryId, userId)) { throw new BaseDaoException("User does not have permission to list users for this directory, " + directoryId + " userId = " + userId); } List result = null; Fqn fqn = cacheUtil.fqn(DbConstants.ALPHABET_ALL_USERS); if (treeCache.exists(fqn, DbConstants.ALPHABET_ALL_USERS)) { // return (List)treeCache.get(fqn, DbConstants.ALPHABET_ALL_USERS); result = (List) treeCache.get(fqn, DbConstants.ALPHABET_ALL_USERS); } else { String queryName = null; if (accessFlag == 1) { queryName = scalabilityManager.getWriteZeroScalability("showallusersalphabetquery"); } else { queryName = scalabilityManager.getReadZeroScalability("showallusersalphabetquery"); } showAllUsersAlphabetQuery = getQueryMapper().getQuery(queryName); try { result = showAllUsersAlphabetQuery.execute(); } catch (Exception e) { throw new BaseDaoException("error in getAllUsersAlphabet() " + showAllUsersAlphabetQuery.getSql(), e); } } if (result == null) { return null; } else { HashSet authorSet = listAuthorsOfDirectory(directoryId, userId, userLogin, accessFlag); HashSet dirauthors = new HashSet(); if (authorSet != null && authorSet.size() > 0) { Iterator it = authorSet.iterator(); while (it.hasNext()) { Directory author = (Directory) it.next(); if (author != null) { dirauthors.add(author.getValue(DbConstants.LOGIN)); } } if (result != null && result.size() > 0 && dirauthors.size() > 0) { List newUsers = new ArrayList(); for (int i = 0; i < result.size(); i++) { Hdlogin hdlogin = (Hdlogin) result.get(i); if (hdlogin != null) { if (!RegexStrUtil.isNull(hdlogin.getValue(DbConstants.LOGIN))) { if (!dirauthors.contains(hdlogin.getValue(DbConstants.LOGIN))) { newUsers.add(result.get(i)); // hdlogin.setValue(DbConstants.AUTHOR, "0"); } } } } treeCache.put(fqn, DbConstants.ALPHABET_ALL_USERS, newUsers); return newUsers; } } } return null; }
From source file:edu.ku.brc.dbsupport.MySQLDMBSUserMgr.java
@Override public List<String> getDatabaseListForUser(final String username) { String[] permsArray = new String[] { "SELECT", "DELETE", "UPDATE", "INSERT", "LOCK TABLES", }; HashSet<String> permsHash = new HashSet<String>(); Collections.addAll(permsHash, permsArray); ArrayList<String> dbNames = new ArrayList<String>(); try {/*from w ww .jav a2 s. c o m*/ if (connection != null) { String userStr = String.format("'%s'@'%s'", username, hostName); String sql = "SHOW GRANTS"; for (Object obj : BasicSQLUtils.querySingleCol(connection, sql)) { boolean isAllDBs = false; String data = (String) obj; String dbName = null; System.out.println("->[" + data + "]"); if (StringUtils.contains(data, userStr)) { // get database name String[] toks = StringUtils.split(data, '`'); if (toks.length > 2) { dbName = toks[1]; } } else if (StringUtils.contains(data, "ON *.* TO")) { //dbNames.add(obj.toString()); isAllDBs = true; } // get permissions String permsStr = StringUtils.substringBetween(data, "GRANT ", " ON"); String[] pToks = StringUtils.split(permsStr, ','); if (pToks != null) { if (pToks.length == 1 && pToks[0].equalsIgnoreCase("ALL PRIVILEGES") && isAllDBs) { dbNames.addAll(getDatabaseList()); } else if (pToks.length >= permsHash.size()) { int cnt = 0; for (String p : pToks) { if (permsHash.contains(p.trim())) { cnt++; } } if (cnt == permsHash.size()) { if (isAllDBs) { dbNames.addAll(getDatabaseList()); break; } else if (dbName != null) { dbNames.add(dbName); } } } } } } } catch (Exception ex) { ex.printStackTrace(); } return dbNames; }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
protected List<Integer> getSelectionIndexes(Collection<? extends Entity> items) { if (items.isEmpty()) { return Collections.emptyList(); }/*from w ww. ja v a 2 s . c om*/ List<Integer> indexes = Lists.newArrayList(); if (datasource instanceof CollectionDatasource.Ordered) { HashSet<Entity> itemSet = new HashSet<>(items); int itemIndex = 0; CollectionDatasource.Ordered orderedDs = (CollectionDatasource.Ordered) datasource; Object id = orderedDs.firstItemId(); while (id != null && !itemSet.isEmpty()) { int rowIndex = impl.convertRowIndexToView(itemIndex); // noinspection unchecked Entity itemById = datasource.getItem(id); if (itemSet.contains(itemById)) { indexes.add(rowIndex); itemSet.remove(itemById); } // noinspection unchecked id = orderedDs.nextItemId(id); itemIndex++; } } else { for (Entity item : items) { int idx = tableModel.getRowIndex(item); if (idx != -1) { indexes.add(impl.convertColumnIndexToView(idx)); } } } return indexes; }
From source file:com.globalsight.webservices.Ambassador4Falcon.java
/** * User may send wrong user ID/name, or user ID/name that belongs to another * company. Filter to get final valid userIds. *///from ww w . j a va2 s. c o m @SuppressWarnings("unchecked") private List<String> getFinalValidUserIdsFromParticipants(WorkflowTemplateInfo wftInfo, WorkflowTask wfTask, String participants) { String srcLocale = wftInfo.getSourceLocale().toString(); String trgLocale = wftInfo.getTargetLocale().toString(); Set<String> projectUserIds = wftInfo.getProject().getUserIds(); HashSet<String> availableUserIds = getAllAvailableAssigneeIds(wfTask.getActivityName(), srcLocale, trgLocale, projectUserIds); Set<String> result = getValidUserIdsFromParticipants(participants); for (Iterator<String> it = result.iterator(); it.hasNext();) { // If is not available user, ignore it. if (!availableUserIds.contains(it.next())) { it.remove(); } } return new ArrayList<String>(result); }
From source file:com.squid.kraken.v4.core.analysis.engine.project.DynamicManager.java
public void loadDomainDynamicContent(Space space, DomainContent content) { Universe univ = space.getUniverse(); Domain domain = space.getDomain();/* w w w . j av a 2 s . c om*/ // check if the domain is in legacy mode (i.e. default is to hide dynamic) boolean isDomainLegacyMode = domain.getInternalVersion() == null; // domainInternalDefautDynamic flag: if legacy mode, hide dynamic object is the default boolean domainInternalDefautDynamic = isDomainLegacyMode ? true : false; // coverage Set: columns already available through defined dimensions HashSet<Column> coverage = new HashSet<Column>(); HashSet<ExpressionAST> metricCoverage = new HashSet<ExpressionAST>(); HashSet<Space> neighborhood = new HashSet<Space>(); HashSet<String> checkName = new HashSet<String>(); boolean isPeriodDefined = false; // String prefix = genDomainPrefixID(space.getUniverse().getProject(), domain); // // evaluate the concrete objects HashSet<String> ids = new HashSet<String>(); // T446: must define the scope incrementally and override the universe ArrayList<ExpressionObject<?>> scope = new ArrayList<ExpressionObject<?>>(); // // sort by level (0 first, ...) List<ExpressionObject<?>> concrete = new ArrayList<ExpressionObject<?>>(); concrete.addAll(content.getDimensions()); concrete.addAll(content.getMetrics()); Collections.sort(concrete, new LevelComparator<ExpressionObject<?>>()); // failed List : keep track of failed evaluation, will try again latter List<ExpressionObject<?>> failed = new ArrayList<ExpressionObject<?>>(); for (ExpressionObject<?> object : concrete) { if (object.getName() != null) { checkName.add(object.getName()); } if (object instanceof Dimension) { // handle Dimension Dimension dimension = (Dimension) object; try { if (dimension.getId() != null) { ids.add(dimension.getId().getDimensionId()); // add also the canonical ID if (dimension.getExpression() != null && dimension.getExpression().getValue() != null) { ids.add(digest(prefix + dimension.getExpression().getValue())); } // add also the Axis ID ids.add(space.A(dimension).getId()); } ExpressionAST expr = parseResilient(univ, domain, dimension, scope); scope.add(object); IDomain image = expr.getImageDomain(); dimension.setImageDomain(image); dimension.setValueType(computeValueType(image)); if (expr instanceof ColumnReference) { ColumnReference ref = (ColumnReference) expr; if (ref.getColumn() != null) { coverage.add(ref.getColumn()); } } else if (image.isInstanceOf(IDomain.OBJECT)) { // it's an sub-domain, we build the space to connect and // will dedup for dynamics Space path = space.S(expr); neighborhood.add(path); } if (dimension.getType() == Type.CONTINUOUS && image.isInstanceOf(IDomain.TEMPORAL)) { isPeriodDefined = true; } } catch (ScopeException e) { // invalid expression, just keep it if (logger.isDebugEnabled()) { logger.debug(("Invalid Dimension '" + domain.getName() + "'.'" + dimension.getName() + "' definition: " + e.getLocalizedMessage())); } failed.add(object); } } else if (object instanceof Metric) { // handle Metric Metric metric = (Metric) object; try { if (metric.getId() != null) { ids.add(metric.getId().getMetricId()); } if (metric.getExpression() != null) { ExpressionAST expr = parseResilient(univ, domain, metric, scope); scope.add(object); metricCoverage.add(expr); } } catch (ScopeException e) { // invalid expression, just keep it if (logger.isDebugEnabled()) { logger.debug(("Invalid Metric '" + domain.getName() + "'.'" + metric.getName() + "' definition: " + e.getLocalizedMessage())); } failed.add(object); } } } // // exclude keys HashSet<Column> keys = new HashSet<Column>(); // filter out the primary-key try { Index pk = space.getTable().getPrimaryKey(); if (pk != null) { for (Column col : pk.getColumns()) { keys.add(col); } } } catch (ScopeException e) { // ignore } // filter out the foreign-keys try { for (ForeignKey fk : space.getTable().getForeignKeys()) { for (KeyPair pair : fk.getKeys()) { keys.add(pair.getExported()); } } } catch (ScopeException | ExecutionException e1) { // ignore } // filter out the relations ? ExtractColumns extractor = new ExtractColumns(); List<Space> subspaces = Collections.emptyList(); try { subspaces = space.S(); } catch (ScopeException | ComputingException e1) { // ignore } for (Space next : subspaces) { Relation relation = next.getRelation(); try { ExpressionAST expr = univ.getParser().parse(relation); List<Column> cols = extractor.apply(expr); keys.addAll(cols); } catch (ScopeException e) { // ignore } } // // populate dynamic dimensions List<RawDImension> periodCandidates = new ArrayList<RawDImension>(); List<Column> columns = Collections.emptyList(); try { columns = space.getTable().getColumns(); } catch (ScopeException | ExecutionException e1) { // ignore } for (Column col : columns) { if (!keys.contains(col) && !coverage.contains(col) && includeColumnAsDimension(col)) { ColumnReference ref = new ColumnReference(col); String expr = ref.prettyPrint(); DimensionPK id = new DimensionPK(domain.getId(), digest(prefix + expr)); if (!ids.contains(id.getDimensionId())) { Type type = Type.INDEX; String name = checkName(normalizeObjectName(col.getName()), checkName); Dimension dim = new Dimension(id, name, type, new Expression(expr), domainInternalDefautDynamic); if (col.getDescription() != null) dim.setDescription(col.getDescription()); dim.setImageDomain(col.getTypeDomain()); dim.setValueType(computeValueType(col.getTypeDomain())); AccessRightsUtils.getInstance().setAccessRights(univ.getContext(), dim, domain); content.add(dim); checkName.add(name); if (col.getTypeDomain().isInstanceOf(IDomain.TEMPORAL) && !isPeriodDefined) { periodCandidates.add(new RawDImension(col, dim)); } } } } // relation and FK for (Space neighbor : subspaces) { if (neighbor.length() == 1 // build only direct paths (the facet // will populate the others && !neighborhood.contains(neighbor)) // dedup if already // concrete // associated with // the same path { Relation relation = neighbor.getRelation(); try { RelationReference ref = new RelationReference(space.getUniverse(), relation, space.getDomain(), neighbor.getDomain()); if (useRelation(relation, ref)) { checkName.add(ref.getReferenceName()); String expr = ref.prettyPrint() + ".$'SELF'";// add the // SELF // parameter DimensionPK id = new DimensionPK(domain.getId(), digest(prefix + expr)); if (!ids.contains(id.getDimensionId())) { String name = ref.getReferenceName(); if (isDomainLegacyMode) { name = checkName(">" + name, checkName); } else { // this is the new naming convention for // sub-domains name = checkName(name + " > ", checkName); } Dimension dim = new Dimension(id, name, Type.INDEX, new Expression(expr), domainInternalDefautDynamic); dim.setDescription("relation to " + neighbor.getDomain().getName()); dim.setValueType(ValueType.OBJECT); dim.setImageDomain(ref.getImageDomain()); AccessRightsUtils.getInstance().setAccessRights(univ.getContext(), dim, domain); content.add(dim); checkName.add(name); } } } catch (ScopeException e) { // ignore } } } // // populate dynamic metrics // // add count metric ExpressionAST count = ExpressionMaker.COUNT(); if (!coverage.contains(count)) { Expression expr = new Expression(count.prettyPrint()); MetricPK metricId = new MetricPK(domain.getId(), digest(prefix + expr.getValue())); if (!ids.contains(metricId.getMetricId())) {// check for natural // definition String name = "COUNT " + domain.getName(); name = checkName(name, checkName); Metric metric = new Metric(metricId, name, expr, domainInternalDefautDynamic); metric.setDescription(domain.getName() + " count"); AccessRightsUtils.getInstance().setAccessRights(univ.getContext(), metric, domain); content.add(metric); checkName.add(name); } } // for (Column col : columns) { if (col.getTypeDomain().isInstanceOf(IDomain.NUMERIC)) { if (!keys.contains(col)) { ExpressionAST total = ExpressionMaker.SUM(new ColumnDomainReference(space, col)); if (!coverage.contains(total)) { Expression expr = new Expression(total.prettyPrint()); MetricPK metricId = new MetricPK(domain.getId(), digest(prefix + expr.getValue())); if (!ids.contains(metricId.getMetricId())) {// check for // natural // definition String name = "SUM " + normalizeObjectName(col.getName()); name = checkName(name, checkName); Metric metric = new Metric(metricId, name, expr, domainInternalDefautDynamic); if (col.getDescription() != null) metric.setDescription(col.getDescription()); AccessRightsUtils.getInstance().setAccessRights(univ.getContext(), metric, domain); content.add(metric); checkName.add(name); } } } } } // // try to recover failed ones for (ExpressionObject<?> object : failed) { try { if (object.getExpression() != null) { if (object instanceof Dimension) { // handle Dimension Dimension dimension = (Dimension) object; ExpressionAST expr = parseResilient(univ, domain, dimension, scope); scope.add(object); IDomain image = expr.getImageDomain(); dimension.setImageDomain(image); dimension.setValueType(computeValueType(image)); } else if (object instanceof Metric) { // handle Metric Metric metric = (Metric) object; ExpressionAST expr = parseResilient(univ, domain, metric, scope); scope.add(object); IDomain image = expr.getImageDomain(); metric.setImageDomain(image); metric.setValueType(computeValueType(image)); } } } catch (ScopeException | CyclicDependencyException e) { // set as permanent error } } // // select a Period if needed boolean isFact = isFactDomain(univ.getContext(), domain.getId()); boolean needPeriod = !isPeriodDefined // if already defined, that's fine && isFact // it must be a fact table, if not there is a good // chance to pollute && content.getMetrics().size() > 1; // and we want at least a // metric different than // COUNT() // select the period if (needPeriod && !periodCandidates.isEmpty()) { DimensionPeriodSelector selector = new DimensionPeriodSelector(space.getUniverse()); RawDImension candidate = selector.selectPeriod(periodCandidates); if (candidate != null) { candidate.dim.setType(Type.CONTINUOUS); } } }
From source file:edu.ucla.cs.scai.canali.core.index.BuildIndex.java
private void indexClasses(IndexWriter writer, HashMap<Integer, IndexedToken> elements) throws Exception { HashSet<Character> vowels = new HashSet<>(); vowels.add('a'); vowels.add('e'); vowels.add('i'); vowels.add('o'); vowels.add('u'); for (int i = 1; i < classUri.length; i++) { if (classUri[i] != null) { HashSet<String> domainOf = new HashSet<>(); HashSet<String> rangeOf = new HashSet<>(); if (classOutProperties[i] == null) { classOutProperties[i] = new HashSet<>(); }// ww w . j ava 2 s . c o m for (int a : classOutProperties[i]) { domainOf.add(propertyUri[a]); } if (classInProperties[i] == null) { classInProperties[i] = new HashSet<>(); } for (int a : classInProperties[i]) { rangeOf.add(propertyUri[a]); } for (String label : classLabels[i]) { label = label.toLowerCase(); ClassToken elementSingular = new ClassToken(classUri[i], label, IndexedToken.SINGULAR, false); indexOntologyElement(writer, elementSingular, domainOf, rangeOf, null); elements.put(elementSingular.getId(), elementSingular); //now create the plural form String pLabel; if (label.endsWith("y") && !vowels.contains(label.charAt(label.length() - 2))) { pLabel = label.substring(0, label.length() - 1) + "ies"; } else if (label.endsWith("s") || label.endsWith("sh") || label.endsWith("ch") || label.endsWith("x") || label.endsWith("z")) { pLabel = label + "es"; } else if (label.equals("person")) { pLabel = "people"; } else { pLabel = label + "s"; } ClassToken elementPlural = new ClassToken(classUri[i], pLabel, IndexedToken.PLURAL, false); indexOntologyElement(writer, elementPlural, domainOf, rangeOf, null); elements.put(elementPlural.getId(), elementPlural); } } } }
From source file:com.globalsight.webservices.Ambassador4Falcon.java
/** * Complete task/*from w w w. j av a 2 s.c o m*/ * * @param p_accessToken * The access token received from the login. * @param p_taskId * Task Id to be completed. * @param p_destinationArrow * This points to the next activity. Null if this task has no * condition node. * @return String in JSON. A sample is like: * {"completeTask":"success"} * @throws WebServiceException */ public String completeTask(String p_accessToken, String p_taskId, String p_destinationArrow) throws WebServiceException { String rtnStr = "success"; checkAccess(p_accessToken, "completeTask"); String returnStr = checkPermissionReturnStr(p_accessToken, Permission.ACTIVITIES_ACCEPT); if (StringUtil.isNotEmpty(returnStr)) return returnStr; try { Assert.assertNotEmpty(p_accessToken, "Access token"); Assert.assertIsInteger(p_taskId); } catch (Exception e) { logger.error(e.getMessage(), e); return makeErrorJson(COMPLETE_TASK, e.getMessage()); } String userName = this.getUsernameFromSession(p_accessToken); String userId = UserUtil.getUserIdByName(userName); // Task object TaskManager taskManager = ServerProxy.getTaskManager(); Task task = null; try { task = taskManager.getTask(Long.parseLong(p_taskId)); if (task == null) return makeErrorJson(COMPLETE_TASK, "Invaild task id."); } catch (RemoteException re) { String msg = "Fail to get task object by taskId : " + p_taskId; logger.error(msg, re); return makeErrorJson(COMPLETE_TASK, msg); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } // Compelte task WebServicesLog.Start activityStart = null; try { Map<Object, Object> activityArgs = new HashMap<Object, Object>(); activityArgs.put("loggedUserName", userName); activityArgs.put("taskId", p_taskId); activityArgs.put("destinationArrow", p_destinationArrow); activityStart = WebServicesLog.start(Ambassador4Falcon.class, "completeTask(p_accessToken,p_taskId,p_destinationArrow)", activityArgs); // Find the user to complete task. WorkflowTaskInstance wfTask = ServerProxy.getWorkflowServer().getWorkflowTaskInstance(userId, task.getId(), WorkflowConstants.TASK_ALL_STATES); task.setWorkflowTask(wfTask); List allAssignees = task.getAllAssignees(); if (allAssignees != null && allAssignees.size() > 0) { if (!allAssignees.contains(userId)) { String message = "'" + userName + "' is not an available assignee for current task " + p_taskId; logger.warn(message); return makeErrorJson(COMPLETE_TASK, message); } } Vector conditionNodes = wfTask.getConditionNodeTargetInfos(); if (conditionNodes != null && conditionNodes.size() > 0) { HashSet<String> arrowNames = new HashSet<String>(); for (int i = 0; i < conditionNodes.size(); i++) { ConditionNodeTargetInfo info = (ConditionNodeTargetInfo) conditionNodes.get(i); arrowNames.add(info.getArrowName()); } if (!arrowNames.contains(p_destinationArrow)) { String message = "\"" + p_destinationArrow + "\" is not a valid outgoing arrow name."; logger.warn(message); return makeErrorJson(COMPLETE_TASK, message); } } TaskImpl dbTask = HibernateUtil.get(TaskImpl.class, task.getId()); ProjectImpl project = (ProjectImpl) dbTask.getWorkflow().getJob().getProject(); WorkflowImpl workflowImpl = (WorkflowImpl) dbTask.getWorkflow(); boolean isCheckUnTranslatedSegments = project.isCheckUnTranslatedSegments(); boolean isRequriedScore = workflowImpl.getScorecardShowType() == 1 ? true : false; boolean isReviewOnly = dbTask.isReviewOnly(); if (isCheckUnTranslatedSegments && !isReviewOnly) { int percentage = SegmentTuvUtil.getTranslatedPercentageForTask(task); if (100 != percentage) { rtnStr = "The task is not 100% translated and can not be completed."; return makeErrorJson(COMPLETE_TASK, rtnStr); } } if (isRequriedScore && isReviewOnly) { if (StringUtil.isEmpty(workflowImpl.getScorecardComment())) { rtnStr = "The task is not scored and can not be completed."; return makeErrorJson(COMPLETE_TASK, rtnStr); } } if (task.getState() == Task.STATE_ACCEPTED) { ServerProxy.getTaskManager().completeTask(userId, task, p_destinationArrow, null); } else { rtnStr = "Cannot complete this task as it is not in 'ACCEPTED' state"; return makeErrorJson(COMPLETE_TASK, rtnStr); } } catch (Exception ex) { String msg = "Fail to complete task : " + p_taskId + " ; " + ex.getMessage(); logger.error(msg, ex); return makeErrorJson(COMPLETE_TASK, msg); } finally { if (activityStart != null) { activityStart.end(); } } return rtnStr; }
From source file:gov.nih.nci.evs.browser.utils.SourceTreeUtils.java
public HashMap getSourceRoots(String CUI, String SAB) { HashSet hset = new HashSet(); HashMap hmap = new HashMap(); TreeItem ti = null;/*from w w w . ja v a 2 s. co m*/ Vector v = new Vector(); String childNavText = "CHD"; boolean hasMoreChildren = false; try { MetaBrowserService mbs = (MetaBrowserService) lbSvc.getGenericExtension("metabrowser-extension"); MetaTree tree = mbs.getMetaNeighborhood(CUI, SAB); MetaTreeNode focus = tree.getCurrentFocus(); ti = new TreeItem(focus.getCui(), focus.getName()); if (isLeaf(focus)) { ti._expandable = false; hmap.put(ti._code, ti); return hmap; } else { ti._expandable = true; } Iterator iterator = focus.getChildren(); if (iterator == null) { hmap.put(ti._code, ti); return hmap; } int knt = 0; hasMoreChildren = false; while (iterator.hasNext()) { MetaTreeNode child = (MetaTreeNode) iterator.next(); if (!hset.contains(child.getCui())) { TreeItem childItem = new TreeItem(child.getCui(), child.getName()); childItem._expandable = true; if (isLeaf(child)) { childItem._expandable = false; } v.add(childItem); hset.add(child.getCui()); } } } catch (Exception e) { } v = SortUtils.quickSort(v); for (int i = 0; i < v.size(); i++) { TreeItem childItem = (TreeItem) v.elementAt(i); ti.addChild(childNavText, childItem); } if (ti != null) { hmap.put(ti._code, ti); } return hmap; }