List of usage examples for java.util LinkedList contains
public boolean contains(Object o)
From source file:uk.ac.diamond.scisoft.analysis.rcp.inspector.InspectionTab.java
@Override protected void repopulateCombos(String oldName, String newName) { if (combos == null) return;/*from www. j ava2 s . c om*/ if (daxes != null && daxes.size() != 1) { super.repopulateCombos(oldName, newName); return; } // cascade through plot axes strings and indices // reduce choice each time int cSize = combos.size() - comboOffset; LinkedList<String> sAxes = getAllAxisNames(); int jmax = daxes.size(); if (jmax == 0) return; boolean fromAxisSelection = oldName != null && newName != null; String a = null; for (int i = 0; i < cSize; i++) { Combo c = combos.get(i + comboOffset); a = (fromAxisSelection && i < jmax) ? daxes.get(i).getSelectedName() : c.getItem(c.getSelectionIndex()); c.removeAll(); if (!sAxes.contains(a)) { a = sAxes.get(0); } if (!fromAxisSelection) { if (i < jmax) daxes.get(i).selectAxis(a, false); } for (String p : sAxes) c.add(p); c.setText(a); sAxes.remove(a); if (paxes != null) { PlotAxisProperty p = paxes.get(i + comboOffset); if (p.isInSet()) { p.setName(a, false); } } } if (a != null && paxes != null) { if (paxes.get(cSize - 1 + comboOffset).isInSet()) { paxes.get(cSize - 1 + comboOffset).setName(a); } } }
From source file:Commands.AddShoesCommand.java
@Override public String executeCommand(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String forwardToJsp = ""; HttpSession session = request.getSession(true); ShoesDao sd = new ShoesDao(); boolean check = true; ArrayList<String> addList = new ArrayList<>(); ArrayList<Shoes> list = new ArrayList<>(); HashMap<Integer, LinkedList<String>> status = new HashMap<>(); HashMap<Integer, LinkedList<Integer>> color = new HashMap<>(); LinkedList<String> s = null; LinkedList<Integer> c = null; if (session.getAttribute("userLogin") != null && ((User) session.getAttribute("userLogin")).is_Admin()) { if (request.getParameter("number") != null) { int num = Integer.parseInt(request.getParameter("number")); for (int n = 1; n < num; n++) { s = new LinkedList<>(); c = new LinkedList<>(); boolean check1 = true; if (request.getParameter("name-" + n) != null && request.getParameter("brand-" + n) != null && request.getParameter("sport-" + n) != null) { if (request.getParameter("name-" + n).isEmpty()) { session.setAttribute("errorMsg", "The name cannot be empty"); return forwardToJsp = "AddShoes.jsp"; }/* w w w .j ava2 s .c o m*/ String name = (String) request.getParameter("name-" + n).substring(0, 1).toUpperCase() + request.getParameter("name-" + n).substring(1).toLowerCase(); int brand = Integer.parseInt(request.getParameter("brand-" + n)); int sport = Integer.parseInt(request.getParameter("sport-" + n)); if (request.getParameter("price-" + n).isEmpty()) { s.add("price cannot be empty"); } double price = Double.parseDouble(request.getParameter("price-" + n)); if (price < 1 || price > 200) { s.add("price range is between 1 to 200"); } if (!sd.findShoes(name).isEmpty()) { s.add("The name is repeated"); } boolean repeat = false; for (int i = 1; i < 4; i++) { if (request.getParameter("color" + i + "-" + n) != null) { int id = Integer.parseInt(request.getParameter("color" + i + "-" + n)); if (c.contains(id)) { repeat = true; } c.add(id); } } if (repeat) { s.add("The color is repeated"); } // String[] files1 = request.getParameterValues("file1-" + n); // String[] files2 = request.getParameterValues("file2-" + n); // String[] files3 = request.getParameterValues("file3-" + n); // long a=Arrays.stream(files1).filter((String st) -> !st.isEmpty()).count(); // long b=Arrays.stream(files1).filter((String st) -> !st.isEmpty()).count(); // long d=Arrays.stream(files1).filter((String st) -> !st.isEmpty()).count(); // if(a==0 || b==0 || d==0){ // s.add("Images is not uploaded"); // } // p.add(files1); // p.add(files2); // p.add(files3); if (!s.isEmpty()) { status.put(n, s); } color.put(n, c); list.add(new Shoes(n, brand, 0, sport, name, price, "")); } else { check = false; break; } } ColorDao cd = new ColorDao(); response.setContentType("text/html"); session.setAttribute("list", list); session.setAttribute("status", status); session.setAttribute("allcolor", color); if (status.isEmpty() && check) { for (int i = 0; i < list.size(); i++) { c = color.get(i + 1); Iterator<Integer> iter = c.iterator(); int count = 1; while (iter.hasNext()) { String name = list.get(i).getName(); int colorId = iter.next(); String colorName = cd.findColorById(colorId).getColor_Name(); String pic = name + "-" + colorName + "-"; sd.addShoes(list.get(i).getBrandID(), colorId, list.get(i).getTypeID(), name, list.get(i).getPrice(), pic); String colo = request.getParameter("cr" + count + "-" + (i + 1)); String[] col = colo.split(","); String UPLOAD_DIRECTORY = request.getServletContext().getRealPath("") + File.separator + "img" + File.separator; int count1 = 1; for (String str : col) { File file = new File(UPLOAD_DIRECTORY + str.substring(4)); File f = new File(UPLOAD_DIRECTORY + pic + count1 + ".jpg"); try { boolean check1 = file.renameTo(f); if (check1 == false) { session.setAttribute("errorMsg", str.substring(4) + " " + UPLOAD_DIRECTORY + pic); return "AddShoes.jsp"; } } catch (SecurityException | NullPointerException se) { session.setAttribute("errorMsg", Arrays.toString(se.getStackTrace())); return "AddShoes.jsp"; } count1++; } count++; } } session.setAttribute("errorMsg", "Shoes is successful added"); // session.removeAttribute("list"); // session.removeAttribute("allcolor"); // session.removeAttribute("status"); } else { session.setAttribute("errorMsg", "Please fill the form with correct information"); forwardToJsp = "AddShoes.jsp"; } } else { session.setAttribute("errorMsg", "Fail to save changes, please refresh the page and try again"); forwardToJsp = "shoes.jsp"; } } else { session.setAttribute("errorMsg", "You are not allowed to access this page"); forwardToJsp = "index.jsp"; } return forwardToJsp; }
From source file:de.uniwue.info6.webapp.lists.ExerciseController.java
/** * @param userQueryFilter//from w w w . ja va 2s.c om * the userQueryFilter to set */ public ArrayList<TableEntry> setQueryFilter(String userFilter, List<String> columns, List<TableEntry> values) { try { LinkedList<Integer> filtered = new LinkedList<Integer>(); ArrayList<TableEntry> filteredValues = new ArrayList<TableEntry>(); if (userFilter != null && !userFilter.trim().isEmpty()) { userFilter = userFilter.trim().toLowerCase(); String column = null; if (userFilter.contains("=")) { String[] parts = userFilter.split("="); column = parts[0]; userFilter = parts[1]; } for (int z = 0; z < values.size(); z++) { for (int i = 0; i < columns.size(); i++) { if (column == null || columns.get(i).toLowerCase().equals(column)) { String value = values.get(z).getValue(i); if (value != null && value.toLowerCase().contains(userFilter)) { if (!filtered.contains(z)) { filtered.add(z); } } } } } filteredValues = new ArrayList<TableEntry>(); for (Integer filter : filtered) { filteredValues.add(values.get(filter)); } return filteredValues; } } catch (Exception e) { filteredUserQueryValues = null; } return null; }
From source file:eu.morfeoproject.fast.catalogue.Catalogue.java
public List<URI> getAllOntologies() { LinkedList<URI> ontologies = new LinkedList<URI>(); ClosableIterator<Statement> cIt = tripleStore.findStatements(ontologiesMetadataGraph, Variable.ANY, RDF.type, OMV.Ontology);/* ww w . ja v a2 s . c o m*/ for (; cIt.hasNext();) { URI uri = cIt.next().getSubject().asURI(); if (!ontologies.contains(uri)) ontologies.add(uri); } cIt.close(); return ontologies; }
From source file:se.vgregion.service.innovationsslussen.idea.IdeaServiceImpl.java
private LinkedList<String> getUserGroupRoleByRoleAndGroup(Idea idea, LinkedList<String> toEmail, String roleName) throws PortalException, SystemException { Role roleInnovationsslussen = roleLocalService.getRole(idea.getCompanyId(), roleName); List<UserGroupRole> roleUsersInnovationsslussen = userGroupRoleLocalService .getUserGroupRolesByGroupAndRole(idea.getGroupId(), roleInnovationsslussen.getRoleId()); for (UserGroupRole userGroupRole : roleUsersInnovationsslussen) { String email = userGroupRole.getUser().getEmailAddress(); if (!toEmail.contains(email)) { toEmail.add(email);// w w w. j av a2s. co m } } return toEmail; }
From source file:util.method.java
public static AbstractOrbacPolicy generateOrBACPolicyFromVMandHostPolicy(LinkedList VMPolicyList, LinkedList<VM> VMList, LinkedList HOSTPolicyList, LinkedList<HOST> HOSTList) throws COrbacException { COrbacCore core = COrbacCore.GetTheInstance(); // create new policy using the Jena implementation AbstractOrbacPolicy p = core.CreatePolicy("policy1", XmlOrbacPolicy.class); // add some abstract entities to the policy // add an organization p.CreateOrganization("superCloud"); String currentOrganization = "superCloud"; String currentActivity = "myActivity"; String currentContext = "default_context"; p.CreateActivityAndInsertIntoOrg(currentActivity, "superCloud"); p.Consider("superCloud", "deploy", currentActivity); p.AddAction("deploy"); LinkedList<String> VMIDMemoryList = new LinkedList<String>(); LinkedList<String> HOSTIDMemoryList = new LinkedList<String>(); /*Generate OrBAC policy from VM List */ for (int i = 0; i < VMPolicyList.size(); i++) { String currentRole = "Role_Permission_" + i; String currentView = "View_Permission_" + i; String currentRuleID = "Permission_" + i; p.CreateRoleAndInsertIntoOrg(currentRole, currentOrganization); p.CreateViewAndInsertIntoOrg(currentView, currentOrganization); //System.out.println("---------------currentRuleID"+currentRuleID); p.AbstractPermission("superCloud", currentRole, currentActivity, currentView, currentContext, currentRuleID);//from w w w . j a va 2 s .c om ArrayList currentVMRule = (ArrayList) VMPolicyList.get(i); String policyType = (String) currentVMRule.get(0); HashMap HOSTProperty = (HashMap) currentVMRule.get(1); HashMap VMProperty = (HashMap) currentVMRule.get(2); if (policyType.equals("permission")) { LinkedList<String> VMIDList = findRelatedVMID(VMProperty, VMList); LinkedList<String> HOSTIDList = findRelatedHOSTID(HOSTProperty, HOSTList); if ((VMIDList.size() == 0) || (HOSTIDList.size() == 0)) return null; //p.AbstractPermission ("superCloud",currentRole,currentActivity,currentView,currentContext,currentRuleID); for (int j = 0; j < VMIDList.size(); j++) { //System.out.print("----------- hahaha This is J"+j); //System.out.print("----------- HOSTLIST size"+HOSTList.size()); for (int k = 0; k < HOSTIDList.size(); k++) { // System.out.print("----------- hahaha This is K"+k); String currentVMID = VMIDList.get(j); String currentHOSTID = HOSTIDList.get(k); //System.out.println("---------------currentHOSTID"+currentHOSTID); //System.out.println("\n---------------currentVMID"+currentVMID); if (!HOSTIDMemoryList.contains(currentHOSTID)) { p.AddSubject(currentHOSTID); HOSTIDMemoryList.add(currentHOSTID); } if (!VMIDMemoryList.contains(currentVMID)) { p.AddObject(currentVMID); VMIDMemoryList.add(currentVMID); } p.Empower(currentOrganization, currentHOSTID, currentRole); p.Use(currentOrganization, currentVMID, currentView); } } } } /*Generate OrBAC policy from HOST List */ for (int j1 = 0; j1 < HOSTPolicyList.size(); j1++) { String currentRole = "Role_Prohibition_" + j1; String currentView = "View_Prohibition_" + j1; String currentRuleID = "Prohibition_" + j1; p.CreateRoleAndInsertIntoOrg(currentRole, currentOrganization); p.CreateViewAndInsertIntoOrg(currentView, currentOrganization); p.AbstractProhibition(currentOrganization, currentRole, currentActivity, currentView, currentContext, currentRuleID); ArrayList currentHOSTRule = (ArrayList) HOSTPolicyList.get(j1); String policyType = (String) currentHOSTRule.get(0); HashMap HOSTProperty = (HashMap) currentHOSTRule.get(1); HashMap VMProperty = (HashMap) currentHOSTRule.get(2); if (policyType.equals("prohibition")) { LinkedList<String> VMIDList = findRelatedVMID(VMProperty, VMList); LinkedList<String> HOSTIDList = findRelatedHOSTID(HOSTProperty, HOSTList); // p.AbstractProhibition ("superCloud",currentRole,currentActivity,currentView,currentContext,currentRuleID); for (int j2 = 0; j2 < VMIDList.size(); j2++) for (int k2 = 0; k2 < HOSTIDList.size(); k2++) { String currentHOSTID = HOSTIDList.get(k2); String currentVMID = VMIDList.get(j2); if (!HOSTIDMemoryList.contains(currentHOSTID)) { p.AddSubject(currentHOSTID); HOSTIDMemoryList.add(currentHOSTID); } if (!VMIDMemoryList.contains(currentVMID)) { p.AddSubject(currentVMID); VMIDMemoryList.add(currentVMID); } p.Empower(currentOrganization, currentHOSTID, currentRole); p.Use(currentOrganization, currentVMID, currentView); } } } return p; }
From source file:util.method.java
public static AbstractOrbacPolicy generateOrBACPolicyFromVMandHostPolicy(LinkedList VMPolicyList, LinkedList<VM> VMList, LinkedList HOSTPolicyList, LinkedList<HOST> HOSTList, int VMNumber, int HOSTNumber) throws COrbacException { COrbacCore core = COrbacCore.GetTheInstance(); // create new policy using the Jena implementation AbstractOrbacPolicy p = core.CreatePolicy("policy" + VMNumber + HOSTNumber, XmlOrbacPolicy.class); // add some abstract entities to the policy // add an organization p.CreateOrganization("superCloud"); String currentOrganization = "superCloud"; String currentActivity = "myActivity"; String currentContext = "default_context"; p.CreateActivityAndInsertIntoOrg(currentActivity, "superCloud"); p.Consider("superCloud", "deploy", currentActivity); p.AddAction("deploy"); LinkedList<String> VMIDMemoryList = new LinkedList<String>(); LinkedList<String> HOSTIDMemoryList = new LinkedList<String>(); /*Generate OrBAC policy from VM List */ for (int i = 0; i < VMPolicyList.size(); i++) { String currentRole = "Role_Permission_" + i; String currentView = "View_Permission_" + i; String currentRuleID = "Permission_" + i; p.CreateRoleAndInsertIntoOrg(currentRole, currentOrganization); p.CreateViewAndInsertIntoOrg(currentView, currentOrganization); //System.out.println("---------------currentRuleID"+currentRuleID); p.AbstractPermission("superCloud", currentRole, currentActivity, currentView, currentContext, currentRuleID);//from w ww. j a v a 2s .c o m ArrayList currentVMRule = (ArrayList) VMPolicyList.get(i); String policyType = (String) currentVMRule.get(0); HashMap HOSTProperty = (HashMap) currentVMRule.get(1); HashMap VMProperty = (HashMap) currentVMRule.get(2); if (policyType.equals("permission")) { LinkedList<String> VMIDList = findRelatedVMID(VMProperty, VMList); LinkedList<String> HOSTIDList = findRelatedHOSTID(HOSTProperty, HOSTList); if ((VMIDList.size() == 0) || (HOSTIDList.size() == 0)) return null; //p.AbstractPermission ("superCloud",currentRole,currentActivity,currentView,currentContext,currentRuleID); for (int j = 0; j < VMIDList.size(); j++) { //System.out.print("----------- hahaha This is J"+j); //System.out.print("----------- HOSTLIST size"+HOSTList.size()); for (int k = 0; k < HOSTIDList.size(); k++) { // System.out.print("----------- hahaha This is K"+k); String currentVMID = VMIDList.get(j); String currentHOSTID = HOSTIDList.get(k); //System.out.println("---------------currentHOSTID"+currentHOSTID); //System.out.println("\n---------------currentVMID"+currentVMID); if (!HOSTIDMemoryList.contains(currentHOSTID)) { p.AddSubject(currentHOSTID); HOSTIDMemoryList.add(currentHOSTID); } if (!VMIDMemoryList.contains(currentVMID)) { p.AddObject(currentVMID); VMIDMemoryList.add(currentVMID); } p.Empower(currentOrganization, currentHOSTID, currentRole); p.Use(currentOrganization, currentVMID, currentView); } } } } /*Generate OrBAC policy from HOST List */ for (int j1 = 0; j1 < HOSTPolicyList.size(); j1++) { String currentRole = "Role_Prohibition_" + j1; String currentView = "View_Prohibition_" + j1; String currentRuleID = "Prohibition_" + j1; p.CreateRoleAndInsertIntoOrg(currentRole, currentOrganization); p.CreateViewAndInsertIntoOrg(currentView, currentOrganization); p.AbstractProhibition(currentOrganization, currentRole, currentActivity, currentView, currentContext, currentRuleID); ArrayList currentHOSTRule = (ArrayList) HOSTPolicyList.get(j1); String policyType = (String) currentHOSTRule.get(0); HashMap HOSTProperty = (HashMap) currentHOSTRule.get(1); HashMap VMProperty = (HashMap) currentHOSTRule.get(2); if (policyType.equals("prohibition")) { LinkedList<String> VMIDList = findRelatedVMID(VMProperty, VMList); LinkedList<String> HOSTIDList = findRelatedHOSTID(HOSTProperty, HOSTList); // p.AbstractProhibition ("superCloud",currentRole,currentActivity,currentView,currentContext,currentRuleID); for (int j2 = 0; j2 < VMIDList.size(); j2++) for (int k2 = 0; k2 < HOSTIDList.size(); k2++) { String currentHOSTID = HOSTIDList.get(k2); String currentVMID = VMIDList.get(j2); if (!HOSTIDMemoryList.contains(currentHOSTID)) { p.AddSubject(currentHOSTID); HOSTIDMemoryList.add(currentHOSTID); } if (!VMIDMemoryList.contains(currentVMID)) { p.AddSubject(currentVMID); VMIDMemoryList.add(currentVMID); } p.Empower(currentOrganization, currentHOSTID, currentRole); p.Use(currentOrganization, currentVMID, currentView); } } } return p; }
From source file:com.redsqirl.workflow.server.Workflow.java
/** * Get a list of DataFlowElements from two list and remove duplicates * /*from ww w . ja va2 s . c o m*/ * @param l1 * @param l2 * @return List of DataFlowElements without duplicates */ protected LinkedList<DataFlowElement> getAllWithoutDuplicate(List<DataFlowElement> l1, List<DataFlowElement> l2) { LinkedList<DataFlowElement> ans = new LinkedList<DataFlowElement>(); ans.addAll(l1); Iterator<DataFlowElement> itCur = l2.iterator(); while (itCur.hasNext()) { DataFlowElement cans = itCur.next(); if (!ans.contains(cans)) { ans.add(cans); } } return ans; }
From source file:org.jsweet.transpiler.JSweetTranspiler.java
private void ts2js(ErrorCountTranspilationHandler transpilationHandler, SourceFile[] files) throws IOException { if (tsCompilationProcess != null && isTscWatchMode()) { return;/*w w w .j a va2 s . co m*/ } if (isTscWatchMode()) { watchedFiles = files; } logger.debug("ts2js: " + Arrays.asList(files)); LinkedList<String> args = new LinkedList<>(); if (System.getProperty("os.name").startsWith("Windows")) { args.addAll(asList("--target", ecmaTargetVersion.name())); } else { args.addAll(asList("--target", ecmaTargetVersion.name())); } if (isUsingModules()) { if (ecmaTargetVersion.higherThan(EcmaScriptComplianceLevel.ES5)) { logger.warn("cannot use old fashionned modules with ES>5 target"); } else { args.add("--module"); args.add(moduleKind.toString()); } } if (ecmaTargetVersion.ordinal() >= EcmaScriptComplianceLevel.ES5.ordinal()) { args.add("--experimentalDecorators"); } if (isTscWatchMode()) { args.add("--watch"); } if (isPreserveSourceLineNumbers()) { args.add("--sourceMap"); } if (isGenerateDeclarations()) { args.add("--declaration"); } args.addAll(asList("--rootDir", tsOutputDir.getAbsolutePath())); // args.addAll(asList("--sourceRoot", tsOutputDir.toString())); if (jsOutputDir != null) { args.addAll(asList("--outDir", jsOutputDir.getAbsolutePath())); } File tscRootFile = getOrCreateTscRootFile(); if (tscRootFile.exists()) { args.add(relativizeTsFile(tscRootFile).toString()); } for (SourceFile sourceFile : files) { String filePath = relativizeTsFile(sourceFile.getTsFile()).toString(); if (!args.contains(filePath)) { args.add(filePath); } } // this may not be necessary because tsc seems to add required modules // automatically for (File f : auxiliaryTsModuleFiles) { String filePath = relativizeTsFile(f).toString(); if (!args.contains(filePath)) { args.add(filePath); } } for (File dir : tsDefDirs) { LinkedList<File> tsDefFiles = new LinkedList<>(); Util.addFiles(".d.ts", dir, tsDefFiles); for (File f : tsDefFiles) { args.add(relativizeTsFile(f).toString()); } } LinkedList<File> tsDefFiles = new LinkedList<>(); Util.addFiles(".d.ts", tsOutputDir, tsDefFiles); for (File f : tsDefFiles) { args.add(relativizeTsFile(f).toString()); } try { logger.info("launching tsc..."); runTSC(transpilationHandler, files, args.toArray(new String[0])); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.redsqirl.workflow.server.Workflow.java
/** * Do sort of the workflow./*from w w w. j av a2s. com*/ * * If the sort is successful, it is a DAG * * @return null if OK, or a description of the error. * @throws RemoteException */ public String topoligicalSort() throws RemoteException { String error = null; LinkedList<DataFlowElement> newList = new LinkedList<DataFlowElement>(); LinkedList<DataFlowElement> queueList = new LinkedList<DataFlowElement>(); Iterator<DataFlowElement> iconIt = element.iterator(); while (iconIt.hasNext()) { DataFlowElement cur = iconIt.next(); if (cur.getInputComponent().values().size() == 0) { queueList.add(cur); } } while (!queueList.isEmpty()) { newList.add(queueList.removeFirst()); iconIt = element.iterator(); while (iconIt.hasNext()) { DataFlowElement cur = iconIt.next(); if (!newList.contains(cur) && !queueList.contains(cur)) { Iterator<List<DataFlowElement>> it = cur.getInputComponent().values().iterator(); boolean allThere = true; while (it.hasNext() && allThere) { allThere = newList.containsAll(it.next()); } if (allThere) { queueList.add(cur); } } } } if (newList.size() < element.size()) { error = LanguageManagerWF.getText("workflow.topologicalSort"); } else { element = newList; } return error; }