List of usage examples for java.util ArrayList isEmpty
public boolean isEmpty()
From source file:ac.ucy.cs.spdx.service.Compatibility.java
@POST @Path("/compatible/") @Consumes(MediaType.TEXT_PLAIN)//from w ww .ja v a2s. co m @Produces(MediaType.APPLICATION_JSON) public String areCompatible(String jsonString) { ObjectMapper mapper = new ObjectMapper(); JsonNode fileNode = null; try { fileNode = mapper.readTree(jsonString); } catch (JsonProcessingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } ArrayList<String> licenses = new ArrayList<String>(); JsonNode licensesJSON = fileNode.get("licenses"); StringBuilder compatibleJSON = new StringBuilder(); for (int i = 0; i < licensesJSON.size(); i++) { String licenseId = licensesJSON.get(i).get("identifier").toString(); licenseId = licenseId.substring(1, licenseId.length() - 1); licenses.add(licenseId); } boolean compatible = LicenseCompatibility.areCompatible(licenses.toArray(new String[licenses.size()])); boolean adjustable = true; ArrayList<License> proposed = new ArrayList<License>(); if (!compatible) { LicenseCompatibility.proposeLicense(licenses.toArray(new String[licenses.size()])); } if (proposed.isEmpty()) { adjustable = false; } compatibleJSON.append( "{\"compatible\":\"" + compatible + "\",\"adjustable\":\"" + adjustable + "\",\"proposals\":["); for (License proposal : proposed) { compatibleJSON.append("{\"identifier\":\"" + proposal.getIdentifier() + "\"},"); } if (adjustable) { compatibleJSON.deleteCharAt(compatibleJSON.length() - 1); } compatibleJSON.append("]}"); return compatibleJSON.toString();// {"licenses":[{"identifier":"Apache-2.0"},{"identifier":"MPL-2.0"}]} }
From source file:io.dockstore.webservice.helpers.QuayImageRegistry.java
/** * For a given tool, update its registry, git, and build information with information from quay.io * /* www .j a va 2 s . c om*/ * @param formatter * @param mapOfBuilds * @param gson * @param tool * @param repo * @param path */ private void updateContainersWithBuildInfo(SimpleDateFormat formatter, Map<String, ArrayList<?>> mapOfBuilds, Gson gson, Tool tool, String repo, String path) { // Get the list of builds from the tool. // Builds contain information such as the Git URL and tags // TODO: work with quay.io to get a better approach such as only the last build for each tag or at the very least paging String urlBuilds = QUAY_URL + "repository/" + repo + "/build/?limit=2147483647"; Optional<String> asStringBuilds = ResourceUtilities.asString(urlBuilds, quayToken.getContent(), client); LOG.info(quayToken.getUsername() + " RESOURCE CALL: {}", urlBuilds); String gitURL = ""; if (asStringBuilds.isPresent()) { String json = asStringBuilds.get(); // parse json using Gson to get the git url of repository and the list of tags Map<String, ArrayList> map = new HashMap<>(); map = (Map<String, ArrayList>) gson.fromJson(json, map.getClass()); ArrayList builds = map.get("builds"); if (builds.size() > 0) { mapOfBuilds.put(path, builds); if (!builds.isEmpty()) { Map<String, Map<String, String>> map2 = (Map<String, Map<String, String>>) builds.get(0); Map<String, String> triggerMetadata = map2.get("trigger_metadata"); if (triggerMetadata != null) { gitURL = triggerMetadata.get("git_url"); } Map<String, String> map3 = (Map<String, String>) builds.get(0); String lastBuild = map3.get("started"); LOG.info(quayToken.getUsername() + " : LAST BUILD: {}", lastBuild); Date date; try { date = formatter.parse(lastBuild); tool.setLastBuild(date); } catch (ParseException ex) { LOG.info(quayToken.getUsername() + ": " + quayToken.getUsername() + " Build date did not match format 'EEE, d MMM yyyy HH:mm:ss Z'"); } } if (tool.getMode() != ToolMode.MANUAL_IMAGE_PATH) { tool.setRegistry(Registry.QUAY_IO); tool.setGitUrl(gitURL); } } } }
From source file:com.ericsson.eif.hansoft.factories.HansoftChangeRequestFactory.java
/** * @param httpServletRequest/*from ww w . ja va2s. com*/ * @param projectIdString * @param projectId * @param taskId * @param minimal * @param hc * @return * @throws URISyntaxException * @throws HPMSdkException * @throws HPMSdkJavaException */ public static HansoftChangeRequest getChangeRequestFromTaskBasic2(HttpServletRequest httpServletRequest, String projectIdString, HPMUniqueID projectId, HPMUniqueID taskId, boolean minimal, HansoftConnector hc) throws URISyntaxException, HPMSdkException, HPMSdkJavaException { String prefix = HansoftManager.getPrefix(httpServletRequest); HansoftChangeRequest changeRequest = new HansoftChangeRequest(); if (hc == null) { hc = HansoftConnector.getAuthorized(httpServletRequest); } final HPMSdkSession session = hc.getHansoftSession(); HPMSessionLock lock = session.SessionLock(); try { changeRequest.setIdentifier(taskId.toString()); URI spAbout = HansoftServiceProviderFactory.getAbout(projectIdString); changeRequest.setServiceProvider(spAbout); changeRequest.setAbout(getAbout(changeRequest.getIdentifier())); String title = hc.isTaskFieldAccessibleTo(projectId, EHPMTaskField.Description) ? session.TaskGetDescription(taskId) : "<Access or visibility restricted>"; changeRequest.setTitle(prefix + title); // If minimal, return only the minimal attributes for e.g. list if (minimal) { return changeRequest; } // Valid for QA Projects String details = hc.isTaskFieldAccessibleTo(projectId, EHPMTaskField.DetailedDescription) ? session.TaskGetDetailedDescription(taskId) : "<Access or visibility restricted>"; changeRequest.setDescription(prefix + details); HPMTaskResourceAllocation assigned = session.TaskGetResourceAllocation(taskId); if (assigned.m_Resources.size() > 0) { ArrayList<Person> contributors = new ArrayList<Person>(); for (HPMTaskResourceAllocationResource resource : assigned.m_Resources) { if (!resource.m_ResourceID.IsValid()) continue; HPMResourceProperties resourceProps = session.ResourceGetProperties(resource.m_ResourceID); Person contributor = new Person(); contributor.setName(resourceProps.m_Name); contributor.setMbox(resourceProps.m_EmailAddress); contributors.add(contributor); } if (!contributors.isEmpty()) changeRequest.setContributors(contributors); } // See http://www.w3.org/TR/xmlschema-2/#dateTime long lastModified = session.TaskGetLastUpdatedTime(taskId); changeRequest.setModified(new Date(lastModified / 1000)); EHPMTaskStatus status = session.TaskGetStatus(taskId); changeRequest.setStatus(prefix + HansoftOSLCMapper.getOSLCStatus(status)); // No need to prefix priority, because it will not contain special // characters (FP bug) EHPMTaskAgilePriorityCategory priority = session.TaskGetAgilePriorityCategory(taskId); changeRequest.setPriority(HansoftOSLCMapper.getOSLCPriority(priority)); float workRemaining = session.TaskGetWorkRemaining(taskId); changeRequest.setWorkRemaining((double) workRemaining); HPMUniqueID taskRefId = session.TaskGetMainReference(taskId); HPMUniqueID parentRefId = session.TaskRefUtilGetParent(taskRefId); // Check if parent is a Task Ref - if not, it's the main project // and we should not set the property as it's not a Task. if (session.UtilIsIDTaskRef(parentRefId)) { HPMUniqueID parentId = session.TaskRefGetTask(parentRefId); changeRequest.setParentTask(parentId.toString()); } // Map Hansoft extended properties HPMTaskCustomColumnDataEnum customData = session.TaskEnumCustomColumnData(taskId); Map<QName, Object> extProps = new HashMap<QName, Object>(customData.m_Hashes.length); for (int i = 0; i < customData.m_Hashes.length; i++) { int hash = customData.m_Hashes[i]; // Check if custom data is accessible to user if (!hc.isCustomColumnAccessibleTo(projectId, hash)) continue; String rawData = session.TaskGetCustomColumnData(taskId, hash); HPMProjectCustomColumnsColumn column = session.ProjectGetCustomColumn(projectId, hash); // Data encoding is required especially for unknown content to // prevent them // from being altered by consumer application especially during // PUT transaction // String data = URLEncoder.encode(getColumnData(session, // column, rawData), "UTF-8"); String data = getColumnData(session, column, rawData); if (data != null) { data = prefix + data; } String propName = AttributesMapper.getInstance().getPropertyNameFromColumnName(column.m_Name); extProps.put(new QName(Constants.HANSOFT_NAMESPACE_EXT, propName), data); } changeRequest.setExtendedProperties(extProps); } finally { lock.dispose(); } return changeRequest; }
From source file:fr.paris.lutece.plugins.workflow.modules.notifygru.service.Validator.java
/** * Checks if is valide build sms./*w w w . j av a 2s . c om*/ * * @param request the request * @param config the config * @param providerService the _provider service * @param locale the locale * @param strApply the str apply * @return the string */ public static String isValideBuildSMS(HttpServletRequest request, TaskNotifyGruConfig config, AbstractServiceProvider providerService, Locale locale, String strApply) { String strUrlRedirector = ""; /*sms*/ ArrayList<String> errors = new ArrayList<String>(); String strMessageSMS = request.getParameter(Constants.PARAMETER_MESSAGE_SMS); if (StringUtils.isBlank(strApply)) { if (StringUtils .isNotBlank(Validator.mandotoryParams(strMessageSMS, Constants.MESSAGE_SMS_FIELD, locale))) { errors.add(Validator.mandotoryParams(strMessageSMS, Constants.MESSAGE_SMS_FIELD, locale)); } if (!Validator.isFreemarkerValid(strMessageSMS, locale, providerService.getInfos(-1))) { Object[] tabRequiredFields = { I18nService.getLocalizedString(Constants.MESSAGE_ERROR_FREEMARKER, locale), }; strUrlRedirector = AdminMessageService.getMessageUrl(request, Constants.MESSAGE_ERROR_FREEMARKER, tabRequiredFields, AdminMessage.TYPE_STOP); } } if (!errors.isEmpty()) { strUrlRedirector = ServiceConfigTaskForm.displayErrorMessage(errors, request); } if (StringUtils.isBlank(strUrlRedirector)) { config.setMessageSMS(strMessageSMS); } return strUrlRedirector; }
From source file:css.variable.converter.CSSVariableConverter.java
/** * Go through existing CSS Files and replace variable access with variable * values/*from w w w . j a v a 2 s . c o m*/ * * @param rootCSSVars All css variables you want to convert from name to value */ private static void editForRelease(ArrayList<CSSVar> rootCSSVars) { for (File cssFile : theCSSList) { ArrayList<CSSVar> localCSSVars = getCSSVars(cssFile, ":local"); for (CSSVar cssVar : rootCSSVars) { if (!localCSSVars.contains(cssVar)) { localCSSVars.add((CSSVar) (cssVar.clone())); } } // This will store info the new text for the file we will write below ArrayList<String> filesNewInfo = new ArrayList<String>(); try { Scanner fileReader = new Scanner(cssFile); while (fileReader.hasNextLine()) { String currentLine = fileReader.nextLine(); // If we find variables, replace them, with their value if (currentLine.contains("var(")) { for (CSSVar var : localCSSVars) { while (currentLine.contains(var.getName())) { currentLine = currentLine.replace("var(" + var.getName() + ")", var.getValue()); } } } // Add new currentLine to be written filesNewInfo.add(currentLine); } fileReader.close(); } catch (FileNotFoundException ex) { Logger.getLogger(CSSVariableConverter.class.getName()).log(Level.SEVERE, null, ex); } // Write the new files below try { BufferedWriter writer = new BufferedWriter(new FileWriter(cssFile.getPath())); while (!filesNewInfo.isEmpty()) { writer.write(filesNewInfo.get(0)); writer.newLine(); filesNewInfo.remove(0); } writer.close(); } catch (IOException ex) { Logger.getLogger(CSSVariableConverter.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:userInterface.CustomerWorkArea.CustomerWorkAreaJPanel.java
private void createChart() { DefaultCategoryDataset CarInspectionDataset = new DefaultCategoryDataset(); ArrayList<CarInspection> carInspectionList = userAccount.getPerson().getCarInspectionHistory() .getCarInspectionHistory();/*from w w w . ja v a 2 s .co m*/ /*At least 2 vital sign records needed to show chart */ if (carInspectionList.isEmpty() || carInspectionList.size() == 1) { JOptionPane.showMessageDialog(this, " At least 2 car Inspection records needed to show chart!", "Warning", JOptionPane.INFORMATION_MESSAGE); return; } for (CarInspection carList : carInspectionList) { CarInspectionDataset.addValue(carList.getAlignment(), "RR", carList.getTimestamp()); CarInspectionDataset.addValue(carList.getBattery(), "HR", carList.getTimestamp()); CarInspectionDataset.addValue(carList.getBrakingSys(), "BP", carList.getTimestamp()); CarInspectionDataset.addValue(carList.getOilCheck(), "WT", carList.getTimestamp()); } JFreeChart carInspectionChart = ChartFactory.createBarChart3D("Car Inspection Chart", "Time Stamp", "Values", CarInspectionDataset, PlotOrientation.VERTICAL, true, false, false); carInspectionChart.setBackgroundPaint(Color.white); CategoryPlot carChartPlot = carInspectionChart.getCategoryPlot(); carChartPlot.setBackgroundPaint(Color.lightGray); CategoryAxis vitalSignDomainAxis = carChartPlot.getDomainAxis(); vitalSignDomainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); NumberAxis vitalSignRangeAxis = (NumberAxis) carChartPlot.getRangeAxis(); vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartFrame chartFrame = new ChartFrame("Chart", carInspectionChart); chartFrame.setVisible(true); chartFrame.setSize(500, 500); }
From source file:be.ibridge.kettle.trans.step.sortrows.SortRows.java
/** Sort the entire vector, if it is not empty *//* ww w . ja v a2 s . c o m*/ public void quickSort(ArrayList elements) { if (log.isDetailed()) logDetailed("Starting quickSort algorithm..."); if (!elements.isEmpty()) { Collections.sort(elements, new Comparator() { public int compare(Object o1, Object o2) { return ((Row) o1).compare((Row) o2, data.fieldnrs, meta.getAscending()); } }); } if (log.isDetailed()) logDetailed("QuickSort algorithm has finished."); }
From source file:dbaccess.servlets.LookupServlet.java
private List<User> checkResults(List<User> allresults, UserData userData) { ArrayList<User> results = new ArrayList<>(); for (User user : allresults) { if (user.matches(userData)) results.add(user);//from w w w. j a v a2s . c om } if (results.isEmpty()) { return null; } else { return results; } }
From source file:dbaccess.servlets.LookupServlet.java
private List<Book> checkResults(List<Book> allresults, BookData bookData) { ArrayList<Book> results = new ArrayList<>(); for (Book book : allresults) { if (book.matches(bookData)) results.add(book);/*from w ww . j a va 2s .c om*/ } if (results.isEmpty()) { return null; } else { return results; } }
From source file:gov.nist.appvet.toolmgr.ToolServiceAdapter.java
public void checkNullArrayList(String fileName, String parameter, ArrayList<String> value) { if ((value == null) || value.isEmpty()) { log.error("Required parameter '" + parameter + "' in file " + fileName + " is null or empty."); }/*from w w w .j a va 2s .co m*/ }