List of usage examples for java.util List iterator
Iterator<E> iterator();
From source file:com.pureinfo.srm.org.OrganizationHelper.java
public static List getOtherResearchTypes() throws PureException { List l = NamedValueHelper.getNamedValues(SRMNamedValueTypes.ORG_TYPE, true); ArrayList list = new ArrayList(l.size() - 3); String[] sExcludes = new String[] { SRMConstants.ORG_TYPE.ADMIN_PART, SRMConstants.ORG_TYPE.COLLEGE, SRMConstants.ORG_TYPE.INSTITUTE, }; for (Iterator iter = l.iterator(); iter.hasNext();) { INamedValue nv = (INamedValue) iter.next(); if (!ArrayUtils.contains(sExcludes, nv.getValue())) { list.add(nv.getValue());/* w w w .j a v a 2s . c o m*/ } } return list; }
From source file:net.sourceforge.fenixedu.applicationTier.Servico.publico.teachersBody.ReadProfessorshipsAndResponsibilitiesByExecutionDegreeAndExecutionPeriod.java
@Atomic public static List run(String executionDegreeId, Integer semester, Integer teacherType) throws FenixServiceException { final ExecutionDegree executionDegree = FenixFramework.getDomainObject(executionDegreeId); List professorships;/*from w w w . j a v a2 s .c o m*/ if (semester.intValue() == 0) { professorships = Professorship.readByDegreeCurricularPlanAndExecutionYear( executionDegree.getDegreeCurricularPlan(), executionDegree.getExecutionYear()); } else { ExecutionSemester executionSemester = executionDegree.getExecutionYear() .getExecutionSemesterFor(semester); professorships = Professorship.readByDegreeCurricularPlanAndExecutionPeriod( executionDegree.getDegreeCurricularPlan(), executionSemester); } List responsibleFors = getResponsibleForsByDegree(executionDegree); List detailedProfessorships = getDetailedProfessorships(professorships, responsibleFors, teacherType); // Cleaning out possible null elements inside the list Iterator itera = detailedProfessorships.iterator(); while (itera.hasNext()) { Object dp = itera.next(); if (dp == null) { itera.remove(); } } Collections.sort(detailedProfessorships, new Comparator() { @Override public int compare(Object o1, Object o2) { DetailedProfessorship detailedProfessorship1 = (DetailedProfessorship) o1; DetailedProfessorship detailedProfessorship2 = (DetailedProfessorship) o2; int result = detailedProfessorship1.getInfoProfessorship().getInfoExecutionCourse().getExternalId() .compareTo(detailedProfessorship2.getInfoProfessorship().getInfoExecutionCourse() .getExternalId()); if (result == 0 && (detailedProfessorship1.getResponsibleFor().booleanValue() || detailedProfessorship2.getResponsibleFor().booleanValue())) { if (detailedProfessorship1.getResponsibleFor().booleanValue()) { return -1; } if (detailedProfessorship2.getResponsibleFor().booleanValue()) { return 1; } } return result; } }); List result = new ArrayList(); Iterator iter = detailedProfessorships.iterator(); List temp = new ArrayList(); while (iter.hasNext()) { DetailedProfessorship detailedProfessorship = (DetailedProfessorship) iter.next(); if (temp.isEmpty() || ((DetailedProfessorship) temp.get(temp.size() - 1)).getInfoProfessorship() .getInfoExecutionCourse() .equals(detailedProfessorship.getInfoProfessorship().getInfoExecutionCourse())) { temp.add(detailedProfessorship); } else { result.add(temp); temp = new ArrayList(); temp.add(detailedProfessorship); } } if (!temp.isEmpty()) { result.add(temp); } return result; }
From source file:com.aurel.track.persist.TDashboardPanelPeer.java
public static List<IField> loadFullChildren(Integer objectID, Connection con) throws TorqueException { LOGGER.debug("Load children for panel:" + objectID); Criteria critChild = new Criteria(); critChild.add(BaseTDashboardFieldPeer.PARENT, objectID); List<IField> result = new ArrayList<IField>(); List torqueList = BaseTDashboardFieldPeer.doSelect(critChild, con); if (torqueList != null) { Iterator itrTorqueList = torqueList.iterator(); while (itrTorqueList.hasNext()) { TDashboardField dashboardField = (TDashboardField) itrTorqueList.next(); TDashboardFieldBean fieldBean = dashboardField.getBean(); updateFieldParameters(fieldBean, con); result.add(fieldBean);/*from w w w. j av a2 s.c om*/ } } return result; }
From source file:Model.Picture.java
public static ArrayList<String> upload(HttpServletRequest request, int type) { ArrayList<String> errors = new ArrayList<String>(); ArrayList<String> pictureNames = new ArrayList<String>(); DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(Constants.UPLOAD_SIZE_THRESHOLD); new File(Constants.TEMP_DIR).mkdirs(); factory.setRepository(new File(Constants.TEMP_DIR)); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(Constants.MAX_UPLOAD_SIZE); try {/*from w w w .j a v a 2 s . c o m*/ List fileItems = upload.parseRequest(request); Iterator i = fileItems.iterator(); while (i.hasNext()) { FileItem fileItem = (FileItem) i.next(); String fileName = fileItem.getName(); if (type == EXCEL_UPLOAD) errors.addAll(upload_excel(fileName, fileItem)); else if (type == PICTURE_UPLOAD) errors.addAll(upload_picture(fileName, fileItem, pictureNames)); } } catch (org.apache.commons.fileupload.FileUploadException e) { e.printStackTrace(System.out); } catch (Exception e) { e.printStackTrace(System.out); } if (type == PICTURE_UPLOAD) DataBaseTools.insertAndUpdateRecords(pictureNames); return errors; }
From source file:com.validation.manager.core.tool.Tool.java
public static void removeDuplicates(List list) { Set set = new HashSet(); List newList = new ArrayList(); for (Iterator iter = list.iterator(); iter.hasNext();) { Object element = iter.next(); if (set.add(element)) { newList.add(element);/* w ww. java 2 s . c o m*/ } } list.clear(); list.addAll(newList); }
From source file:kr.co.aim.nanoframe.nanoFrameServiceProxy.java
@Deprecated public static Map<String, Map<String, String>> getObjectAttributeDef() { Map<String, Map<String, String>> returns = new HashMap<String, Map<String, String>>(); ObjectAttributeMap attributeMap = getObjectAttributeMap(); Map<String, List<ObjectAttributeDef>> map = attributeMap.getMap(); Set<String> set = map.keySet(); for (Iterator<String> iterator = set.iterator(); iterator.hasNext();) { String string = (String) iterator.next(); String key = string.substring(string.lastIndexOf(".") + 1, string.length()); if (ObjectAttributeMap.ExtendedC_Type.equals(key)) { List<ObjectAttributeDef> list = map.get(string); for (Iterator<ObjectAttributeDef> iter = list.iterator(); iter.hasNext();) { ObjectAttributeDef object = iter.next(); if (returns.containsKey(object.getTypeName())) { returns.get(object.getTypeName()).put(object.getAttributeName(), ""); } else { Map<String, String> objDefs = new HashMap<String, String>(); objDefs.put(object.getAttributeName(), ""); returns.put(object.getTypeName(), objDefs); }// w ww .j av a2 s .c om } } } return returns; }
From source file:com.qmetry.qaf.automation.support.perfecto.PefectoDeviceAppInstaller.java
@DataProvider(name = "deviceListProvider") private static Iterator<Object[]> getConnectedDevices(ITestContext context) throws ConfigurationException { List<Object[]> lst = new ArrayList<Object[]>(); Map<String, String> params = new HashMap<String, String>(); params.put("os", "driver.capabilities.platformName"); params.put("inUse", "false"); for (Object deviceId : getDeviceIds(params)) { lst.add(new Object[] { deviceId }); }/*ww w.j a va2s . c om*/ return lst.iterator(); }
From source file:io.github.jeddict.relation.mapper.spec.JoinColumnFinder.java
private static JoinColumn findJoinColumn(String name, List<JoinColumn> joinColumns, boolean mapKey) { JoinColumn joinColumn = null;/* w w w. j ava2 s . c om*/ boolean created = false; // List<JoinColumn> joinColumnList = joinColumns; if (joinColumns != null) { for (Iterator<? extends JoinColumn> it = joinColumns.iterator(); it.hasNext();) { JoinColumn column = it.next(); if (name.equals(column.getName())) { joinColumn = column; created = true; break; } else if (StringUtils.isBlank(column.getName())) { // it.remove(); } } if (!created) { joinColumn = new JoinColumn(); joinColumn.setImplicitName(name); joinColumns.add(joinColumn); } } return joinColumn; }
From source file:com.baasbox.service.storage.DocumentService.java
public static ODocument get(String collectionName, String rid, PartsParser parser) throws IllegalArgumentException, InvalidCollectionException, InvalidModelException, ODatabaseException, DocumentNotFoundException, InvalidCriteriaException { DocumentDao dao = DocumentDao.getInstance(collectionName); ODocument doc = dao.get(rid);/*from ww w.j a v a2 s . c o m*/ if (parser.isMultiField()) { Object v = doc.field(parser.treeFields()); if (v == null) { throw new DocumentNotFoundException( "Unable to find a field " + parser.treeFields() + " into document:" + rid); } } StringBuffer q = new StringBuffer(); q.append("select ").append(parser.fullTreeFields()).append(" as ").append(OBJECT_QUERY_ALIAS) .append(" from ").append(collectionName); q.append(" where @rid=").append(rid); List<ODocument> odocs = DocumentDao.getInstance(collectionName).selectByQuery(q.toString()); ODocument result = (odocs != null && !odocs.isEmpty()) ? odocs.iterator().next() : null; //TODO: /*if(parser.isArray()){ try { ArrayNode an = (ArrayNode)mp.readTree(result.toJSON()).get(parser.last().getName()); PartsLexer.ArrayField af = (PartsLexer.ArrayField)parser.last(); if(an.size()<af.arrayIndex){ throw new InvalidModelException("The index requested does not exists in model"); }else{ String json = String.format("{\"%s[%d]\":\"%s\"}",parser.last().getName(),af.arrayIndex,an.get(af.arrayIndex).textValue()); result = new ODocument().fromJSON(json); System.out.println("JSON:"+result.toJSON()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }*/ return result; }
From source file:com.liangc.hq.base.utils.MonitorUtils.java
/** * Method findDefaultChildResourceId//from www. jav a 2 s . com * * Return the id of the first child resource type (according to * whatever order in which the BizApp lists them) for which the * parent resource has one or more defined child resources. * * @param resourceTypes a <code>List</code> of * <code>AppdefResourceTypeValue</code> objects * @param resourceCounts a <code>Map</code> of resource counts * keyed by resource type name * @return Integer */ public static Integer findDefaultChildResourceId(List resourceTypes, Map resourceCounts) { if (resourceTypes != null && resourceCounts != null) { Iterator i = resourceTypes.iterator(); while (i.hasNext()) { AppdefResourceTypeValue type = (AppdefResourceTypeValue) i.next(); Integer count = (Integer) resourceCounts.get(type.getName()); if (count != null && count.intValue() > 0) { return type.getId(); } } } return null; }