List of usage examples for java.lang String join
public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements)
From source file:com.formkiq.core.service.workflow.WorkflowEditorServiceImplTest.java
/** * testEventIdremoveprintstep03()/*w w w .j ava 2s . co m*/ * remove 10th print step. */ @Test public void testEventIdremoveprintstep03() { // given String[] fieldids = new String[] { "10" }; this.workflow.setPrintsteps(new ArrayList<>(Arrays.asList("1", "2", "3"))); // when expect(this.flow.getData()).andReturn(this.mockarchive); expect(this.mockarchive.getWorkflow()).andReturn(this.workflow); replayAll(); this.ws.eventIdremoveprintstep(this.flow, fieldids); // then verifyAll(); assertEquals("1,2,3", String.join(",", this.workflow.getPrintsteps())); }
From source file:controllers.WorkflowViewController.java
public String submitAndRegisterWf(String type, String id, Workflow workflow, List<DatasetBean> selectedDatasets) throws ConnectException, IllegalArgumentException, SubmitFailedException { SpaceAndProjectCodes spaceandproject = getSpaceAndProjects(type, id); String spaceCode = spaceandproject.space; String projectCode = spaceandproject.project; ParameterSet params = workflow.getParameters(); List<Property> factors = new ArrayList<Property>(); XMLParser xmlParser = new XMLParser(); for (Map.Entry<String, Parameter> entry : workflow.getData().getData().entrySet()) { String key = entry.getKey(); Parameter value = entry.getValue(); if (key.contains("input")) { List<String> files = (List<String>) value.getValue(); List<String> inputFiles = new ArrayList<String>(); for (String f : files) { String[] splitted = f.split("/"); String fileName = splitted[splitted.length - 1]; inputFiles.add(fileName); }//from w ww . j av a2s . c o m System.out.println(inputFiles.toString()); String concat = String.join("; ", inputFiles); System.out.println(concat); Property newProperty = new Property("input_files", concat, PropertyType.Property); factors.add(newProperty); } else { Property newProperty = new Property("database", value.getValue().toString().replace("/lustre_cfc/qbic/reference_genomes/", ""), PropertyType.Property); factors.add(newProperty); } } for (String p : params.getParamNames()) { Parameter par = params.getParam(p); String[] splitted = par.getTitle().split("\\."); String parName = splitted[splitted.length - 1].replace(" ", "_").toLowerCase(); Property newProperty = new Property(parName, par.getValue().toString(), PropertyType.Property); factors.add(newProperty); } String qProperties = ""; try { qProperties = xmlParser.toString(xmlParser.createXMLFromProperties(factors)); System.out.println(qProperties); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } String experimentCode = registerWFExperiment(spaceCode, projectCode, workflow.getExperimentType(), workflow.getID(), workflow.getVersion(), user, qProperties); List<String> parents = getConnectedSamples(selectedDatasets); String sampleType = workflow.getSampleType(); String sampleCode = registerWFSample(spaceCode, projectCode, experimentCode, sampleType, parents, selectedDatasets); String openbisId = String.format("%s-%s-%s-%s", spaceCode, projectCode, experimentCode, sampleCode); LOGGER.info( "User: " + user + " is submitting workflow " + workflow.getID() + " openbis id is:" + openbisId); String submit_id = submitter.submit(workflow, openbisId, user); LOGGER.info("Workflow has guse id: " + submit_id); setWorkflowID(spaceCode, projectCode, experimentCode, submit_id); return openbisId; }
From source file:com.hotelbeds.distribution.hotel_api_sdk.HotelApiClient.java
public BookingListRS list(LocalDate start, LocalDate end, int from, int to, BookingListFilterStatus status, BookingListFilterType filterType, Properties properties, List<String> countries, List<String> destinations, String clientReference, List<Integer> hotels) throws HotelApiSDKException { final Map<String, String> params = new HashMap<>(); params.put("start", start.toString()); params.put("end", end.toString()); params.put("from", Integer.toString(from)); params.put("to", Integer.toString(to)); if (status != null) { params.put("status", status.name()); }//from w w w . java2s . c om if (filterType != null) { params.put("filterType", filterType.name()); } if (countries != null && !countries.isEmpty()) { params.put("country", String.join(",", countries)); } if (destinations != null && !destinations.isEmpty()) { params.put("destination", String.join(",", destinations)); } if (hotels != null && !hotels.isEmpty()) { params.put("hotel", hotels.stream().map(hotelCode -> hotelCode.toString()).collect(Collectors.joining(","))); } if (clientReference != null) { params.put("clientReference", clientReference); } addPropertiesAsParams(properties, params); return (BookingListRS) callRemoteAPI(params, HotelApiPaths.BOOKING_LIST); }
From source file:com.gmt2001.TwitchAPIv5.java
/** * Builds a RegExp String to match cheer emotes from Twitch * * @return/*from w w w.j a v a2 s . c o m*/ */ public String GetCheerEmotesRegex() { String[] emoteList; JSONObject jsonInput; JSONArray jsonArray; if (cheerEmotes == "") { jsonInput = GetCheerEmotes(); if (jsonInput.has("actions")) { jsonArray = jsonInput.getJSONArray("actions"); emoteList = new String[jsonArray.length()]; for (int idx = 0; idx < jsonArray.length(); idx++) { emoteList[idx] = "\\b" + jsonArray.getJSONObject(idx).getString("prefix") + "\\d+\\b"; } cheerEmotes = String.join("|", emoteList); } } return cheerEmotes; }
From source file:com.formkiq.core.service.workflow.WorkflowEditorServiceImplTest.java
/** * testEventStepdown01().//from w ww . j av a2s . c om * _eventId_stepdown up. * @throws IOException IOException */ @Test public void testEventStepdown01() throws IOException { // given Workflow wf = expectAction(); replayAll(); this.ws.eventIdstepdown(this.flow, this.request, new String[] { "0" }); // then verifyAll(); assertEquals("2,1,3", String.join(",", wf.getSteps())); assertEquals("1,2,3", String.join(",", wf.getPrintsteps())); }
From source file:org.outofbits.sesame.schemagen.SchemaGeneration.java
/** * Gets the root resource of the given vocabulary, or null if n such reosurce could be found. * * @param vocabulary {@link Model} containing all statements of the vocabulary. * @return the root {@link Resource} or null, if no such resource could be found. * @throws SchemaGenerationException if there are more than one root resource. */// w ww .ja v a2s . c om private Resource getRootResource(Model vocabulary) throws SchemaGenerationException { assert vocabulary != null; Resource vocabularyRootResource = null; // Using Namespace for getting the root resource. if (vocabularyOptions.baseNamespace() != null) { Optional<Resource> optionalVocabRootResource = vocabulary .filter(valueFactory.createIRI(vocabularyOptions.baseNamespace()), null, null).subjects() .stream().findFirst(); if (optionalVocabRootResource.isPresent()) { vocabularyRootResource = optionalVocabRootResource.get(); } } if (vocabularyRootResource == null) { // Getting the root resource that is an instance of a known vocabulary class. for (IRI clazz : VOCAB_CLASSES) { Set<Resource> vocabRootResources = vocabulary.filter(null, RDF.TYPE, clazz).subjects(); if (vocabRootResources.size() > 1) { throw new SchemaGenerationException(String.format("Ambiguous root resources (%s).", String.join( ", ", vocabRootResources.stream().map(Resource::stringValue).collect(Collectors.toList())))); } else if (vocabRootResources.size() == 1) { Resource currentVocabularyRootResource = vocabRootResources.iterator().next(); if (vocabularyRootResource == null) { vocabularyRootResource = currentVocabularyRootResource; } else if (!currentVocabularyRootResource.equals(vocabularyRootResource)) { throw new SchemaGenerationException(String.format("Ambiguous root resources (%s, %s).", vocabularyRootResource, currentVocabularyRootResource)); } } } } return vocabularyRootResource; }
From source file:com.formkiq.core.service.workflow.WorkflowEditorServiceImplTest.java
/** * testEventStepdown02().//from w ww . jav a 2 s . c o m * _eventId_stepdown up at max size. * @throws IOException IOException */ @Test public void testEventStepdown02() throws IOException { // given // when Workflow wf = expectAction(); replayAll(); this.ws.eventIdstepdown(this.flow, this.request, new String[] { "2" }); // then verifyAll(); assertEquals("1,2,3", String.join(",", wf.getSteps())); assertEquals("1,2,3", String.join(",", wf.getPrintsteps())); }
From source file:net.sf.jabref.model.entry.BibEntry.java
public Optional<FieldChange> putKeywords(Collection<String> keywords, String separator) { Objects.requireNonNull(keywords); Optional<String> oldValue = this.getFieldOptional(FieldName.KEYWORDS); if (keywords.isEmpty()) { // Clear keyword field if (oldValue.isPresent()) { return this.clearField(FieldName.KEYWORDS); } else {//from w w w .jav a2 s . c o m return Optional.empty(); } } // Set new keyword field String newValue = String.join(separator, keywords); return this.setField(FieldName.KEYWORDS, newValue); }
From source file:com.netflix.spinnaker.clouddriver.kubernetes.v2.op.job.KubectlJobExecutor.java
private List<String> kubectlNamespacedGet(KubernetesV2Credentials credentials, List<KubernetesKind> kind, String namespace) {/* w w w . j a v a2s. c o m*/ List<String> command = kubectlNamespacedAuthPrefix(credentials, namespace); command.add("-o"); command.add("json"); command.add("get"); command.add(String.join(",", kind.stream().map(KubernetesKind::toString).collect(Collectors.toList()))); return command; }
From source file:com.github.lindenb.mscheduler.MScheduler.java
private int list(final String argv[]) { Cursor c = null;//from w w w. j a va2 s .c o m final Transaction txn = null; try { final CommandLineParser parser = new DefaultParser(); this.cmdLine = parser.parse(this.options, argv); if (this.cmdLine.hasOption(OPTION_HELP)) { printHelp("Build scheduler from Makefile"); return 0; } if (!this.cmdLine.getArgList().isEmpty()) { LOG.error("Illegal number of arguments"); return -1; } if (this.parseWorkingDirectory() != 0) return -1; openEnvironement(txn, false, true); c = this.targetsDatabase.openCursor(txn, null); final DatabaseEntry key = new DatabaseEntry(); final DatabaseEntry data = new DatabaseEntry(); final Task.Binding taskBinding = new Task.Binding(); while (c.getNext(key, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) { final Task t = taskBinding.entryToObject(data); if (t.getName().contains("<")) continue;//<ROOT> System.out.print(t.getName()); System.out.print('\t'); System.out.print(t.processId == null ? "*" : t.processId); System.out.print('\t'); System.out.print(t.targetStatus); System.out.print('\t'); System.out.print(t.md5()); System.out.print('\t'); System.out.print(t.duration()); System.out.print('\t'); System.out.print(t.shellScriptFile == null ? "*" : t.shellScriptFile); //System.out.print('\t'); ///System.out.print(graph.mustRemake(t)); System.out.print('\t'); System.out.print(String.join(" ", t.getPrerequisites())); System.out.println(); } return 0; } catch (final Exception err) { LOG.error("Boum", err); return -1; } finally { IoUtils.close(c); close(); } }