Example usage for java.lang String join

List of usage examples for java.lang String join

Introduction

In this page you can find the example usage for java.lang String join.

Prototype

public static String join(CharSequence delimiter, Iterable<? extends CharSequence> elements) 

Source Link

Document

Returns a new String composed of copies of the CharSequence elements joined together with a copy of the specified delimiter .

Usage

From source file:com.yahoo.parsec.filters.RequestResponeLoggingFilterTest.java

private String createLogStringPattern(String requestMethod, String url, String queryString,
        Map<String, Collection<String>> reqHeaders, String reqBodyJson, int responseCode,
        Map<String, Collection<String>> respHeaders, String respBodyJson) throws JsonProcessingException {

    Map<String, String> headers = reqHeaders.entrySet().stream()
            .collect(Collectors.toMap(Map.Entry::getKey, e -> String.join(",", e.getValue())));

    String reqHeaderString = _OBJECT_MAPPER.writeValueAsString(headers);

    headers = respHeaders.entrySet().stream()
            .collect(Collectors.toMap(Map.Entry::getKey, e -> String.join(",", e.getValue())));

    String respHeaderString = _OBJECT_MAPPER.writeValueAsString(headers);

    String pattern = String.format(
            "{" + "\"time\":\"${json-unit.any-number}\"," + "\"request\": {" + "\"method\": \"%s\","
                    + "\"uri\": \"%s\"," + "\"query\": \"%s\"," + "\"headers\": %s," + "\"payload\": \"%s\""
                    + "}," + "\"response\": {" + "\"status\": %d," + "\"headers\": %s," + "\"payload\": \"%s\""
                    + "}," + "\"progress\": {" + "\"namelookup_time\": \"${json-unit.any-number}\","
                    + "\"connect_time\": \"${json-unit.any-number}\","
                    + "\"pretransfer_time\": \"${json-unit.any-number}\","
                    + "\"starttransfer_time\": \"${json-unit.any-number}\","
                    + "\"total_time\":\"${json-unit.any-number}\"" + "}" + "}",
            requestMethod, url, queryString, reqHeaderString, StringEscapeUtils.escapeJson(reqBodyJson),
            responseCode, respHeaderString, StringEscapeUtils.escapeJson(respBodyJson));

    return pattern;
}

From source file:com.viewer.controller.ViewerController.java

@RequestMapping(value = "/ViewDocument", method = RequestMethod.POST, headers = {
        "Content-type=application/json" })
@ResponseBody/* w  ww  .  j  a  v  a  2 s  . c om*/
public ViewDocumentResponse viewDoc(@RequestBody ViewDocumentParameters params, HttpServletRequest request)
        throws Exception {
    // To Set License
    License lic = new License();
    lic.setLicense(_licensePath);
    params.setUseHtmlBasedEngine(true);
    if (params.getUseHtmlBasedEngine()) {

        DocumentInfoContainer docInfo = _htmlHandler.getDocumentInfo(new DocumentInfoOptions(params.getPath()));
        int maxWidth = 0;
        int maxHeight = 0;
        for (PageData pageData : docInfo.getPages()) {
            if (pageData.getHeight() > maxHeight) {
                maxHeight = pageData.getHeight();
                maxWidth = pageData.getWidth();
            }
        }
        FileData fileData = new FileData();

        fileData.setDateCreated(new Date());
        fileData.setDateModified(docInfo.getLastModificationDate());
        fileData.setPageCount(docInfo.getPages().size());
        fileData.setPages(docInfo.getPages());
        fileData.setMaxWidth(maxWidth);
        fileData.setMaxHeight(maxHeight);

        ViewDocumentResponse result = new ViewDocumentResponse();
        result.setPageCss(new String[0]);
        result.setLic(true);
        result.setPdfDownloadUrl(GetPdfDownloadUrl(params));
        result.setPdfPrintUrl(GetPdfPrintUrl(params));
        result.setUrl(GetFileUrl(params));
        result.setPath(params.getPath());
        result.setName(params.getPath());
        try {
            result.setDocumentDescription(
                    (new FileDataJsonSerializer(fileData, new FileDataOptions())).Serialize(false));
        } catch (ParseException x) {
            throw new ServletException(x);
        }
        result.setDocumentDescription(
                (new FileDataJsonSerializer(fileData, new FileDataOptions())).Serialize(false));
        result.setDocType(docInfo.getDocumentType());
        result.setFileType(docInfo.getFileType());

        HtmlOptions htmlOptions = new HtmlOptions();
        htmlOptions.setResourcesEmbedded(true);

        htmlOptions.setHtmlResourcePrefix("/GetResourceForHtml?documentPath=" + params.getPath()
                + "&pageNumber={page-number}&resourceName=");

        if (!DotNetToJavaStringHelper.isNullOrEmpty(params.getPreloadPagesCount().toString())
                && params.getPreloadPagesCount().intValue() > 0) {
            htmlOptions.setPageNumber(1);
            htmlOptions.setCountPagesToConvert(params.getPreloadPagesCount().intValue());
        }

        String[] cssList = null;

        RefObject<ArrayList<String>> tempRef_cssList = new RefObject<ArrayList<String>>(cssList);

        List<PageHtml> htmlPages = GetHtmlPages(params.getPath(), htmlOptions);
        cssList = tempRef_cssList.argValue;

        ArrayList<String> pagesContent = new ArrayList<String>();
        for (PageHtml page : htmlPages) {
            pagesContent.add(page.getHtmlContent());
        }
        String[] htmlContent = pagesContent.toArray(new String[0]);
        result.setPageHtml(htmlContent);
        result.setPageCss(new String[] { String.join(" ", temp_cssList) });

        for (int i = 0; i < result.getPageHtml().length; i++) {
            String html = result.getPageHtml()[i];
            int indexOfScript = html.indexOf("script");
            if (indexOfScript > 0) {
                result.getPageHtml()[i] = html.substring(0, indexOfScript);
            }
        }

        return result;

    } else {

        DocumentInfoContainer docInfo = _imageHandler
                .getDocumentInfo(new DocumentInfoOptions(params.getPath()));
        int maxWidth = 0;
        int maxHeight = 0;
        for (PageData pageData : docInfo.getPages()) {
            if (pageData.getHeight() > maxHeight) {
                maxHeight = pageData.getHeight();
                maxWidth = pageData.getWidth();
            }
        }
        FileData fileData = new FileData();

        fileData.setDateCreated(new Date());
        fileData.setDateModified(docInfo.getLastModificationDate());
        fileData.setPageCount(docInfo.getPages().size());
        fileData.setPages(docInfo.getPages());
        fileData.setMaxWidth(maxWidth);
        fileData.setMaxHeight(maxHeight);

        ViewDocumentResponse result = new ViewDocumentResponse();
        result.setPageCss(new String[0]);
        result.setLic(true);
        result.setPdfDownloadUrl(GetPdfDownloadUrl(params));
        result.setPdfPrintUrl(GetPdfPrintUrl(params));
        params.setUseHtmlBasedEngine(true);
        result.setUrl(GetFileUrl(params.getPath(), true, false, params.getFileDisplayName(),
                params.getWatermarkText(), params.getWatermarkColor(), params.getWatermarkPostion(),
                params.getWatermarkWidth(), params.getIgnoreDocumentAbsence(), params.getUseHtmlBasedEngine(),
                params.getSupportPageRotation()));
        result.setPath(params.getPath());
        result.setName(params.getPath());
        result.setDocumentDescription(
                (new FileDataJsonSerializer(fileData, new FileDataOptions())).Serialize(false));
        result.setDocType(docInfo.getDocumentType());
        result.setFileType(docInfo.getFileType());

        int[] pageNumbers = new int[docInfo.getPages().size()];
        int count = 0;
        for (PageData page : docInfo.getPages()) {

            pageNumbers[count] = page.getNumber();
            count++;
        }
        String applicationHost = request.getScheme() + "://" + request.getServerName() + ":"
                + request.getServerPort();
        String[] imageUrls = ImageUrlHelper.GetImageUrls(applicationHost, pageNumbers, params);

        result.setImageUrls(imageUrls);
        return result;

    }

}

From source file:com.formkiq.core.service.workflow.WorkflowEditorServiceImplTest.java

/**
 * testEventForms01()./*from  w  w  w  . ja  v a2 s.  co  m*/
 * _eventId_forms.
 * @throws IOException IOException
 */
@Test
public void testEventForms01() throws IOException {
    // given
    ArchiveDTO arch = new ArchiveDTO();
    Workflow wf = new Workflow();

    FormJSON form0 = TestDataBuilder.createSimpleForm();
    FormJSON form1 = TestDataBuilder.createStoreReceipt();

    wf.setSteps(Arrays.asList(form0.getUUID(), form1.getUUID()));

    arch.setWorkflow(wf);
    arch.addForm(form0);
    arch.addForm(form1);

    // when
    expect(this.flow.getData()).andReturn(arch);

    replayAll();
    FormJSONField result = this.ws.eventIdforms(this.flow, new String[] { "81" });

    // then
    verifyAll();

    assertEquals("Simple Form[" + form0.getUUID() + "],Store Receipt[" + form1.getUUID() + "]",
            String.join(",", result.getOptions()));
}

From source file:com.ggvaidya.scinames.dataset.DatasetSceneController.java

private void setupTableWithChanges(TableView<Change> tv, Dataset tp) {
    tv.setEditable(true);//from  w  w w  .  jav  a2  s. c o  m
    tv.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    tv.getColumns().clear();

    TableColumn<Change, ChangeType> colChangeType = new TableColumn<>("Type");
    colChangeType.setCellFactory(ComboBoxTableCell.forTableColumn(new ChangeTypeStringConverter(),
            ChangeType.ADDITION, ChangeType.DELETION, ChangeType.RENAME, ChangeType.LUMP, ChangeType.SPLIT,
            ChangeType.COMPLEX, ChangeType.ERROR));
    colChangeType.setCellValueFactory(new PropertyValueFactory<>("type"));
    colChangeType.setPrefWidth(100.0);
    colChangeType.setEditable(true);
    tv.getColumns().add(colChangeType);

    TableColumn<Change, ObservableSet<Name>> colChangeFrom = new TableColumn<>("From");
    colChangeFrom.setCellFactory(TextFieldTableCell.forTableColumn(new NameSetStringConverter()));
    colChangeFrom.setCellValueFactory(new PropertyValueFactory<>("from"));
    colChangeFrom.setPrefWidth(200.0);
    colChangeFrom.setEditable(true);
    tv.getColumns().add(colChangeFrom);

    TableColumn<Change, ObservableSet<Name>> colChangeTo = new TableColumn<>("To");
    colChangeTo.setCellFactory(TextFieldTableCell.forTableColumn(new NameSetStringConverter()));
    colChangeTo.setCellValueFactory(new PropertyValueFactory<>("to"));
    colChangeTo.setPrefWidth(200.0);
    colChangeTo.setEditable(true);
    tv.getColumns().add(colChangeTo);

    TableColumn<Change, String> colExplicit = new TableColumn<>("Explicit or implicit?");
    colExplicit.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    features.getValue().getDataset().isChangeImplicit(features.getValue()) ? "Implicit"
                            : "Explicit"));
    tv.getColumns().add(colExplicit);

    ChangeFilter cf = datasetView.getProjectView().getProject().getChangeFilter();
    TableColumn<Change, String> colFiltered = new TableColumn<>("Eliminated by filter?");
    colFiltered.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    cf.test(features.getValue()) ? "Allowed" : "Eliminated"));
    tv.getColumns().add(colFiltered);

    TableColumn<Change, String> colNote = new TableColumn<>("Note");
    colNote.setCellFactory(TextFieldTableCell.forTableColumn());
    colNote.setCellValueFactory(new PropertyValueFactory<>("note"));
    colNote.setPrefWidth(100.0);
    colNote.setEditable(true);
    tv.getColumns().add(colNote);

    TableColumn<Change, String> colCitations = new TableColumn<>("Citations");
    colCitations.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    features.getValue().getCitationStream().map(citation -> citation.getCitation()).sorted()
                            .collect(Collectors.joining("; "))));
    tv.getColumns().add(colCitations);

    TableColumn<Change, String> colGenera = new TableColumn<>("Genera");
    colGenera.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    String.join(", ", features.getValue().getAllNames().stream().map(n -> n.getGenus())
                            .distinct().sorted().collect(Collectors.toList()))));
    tv.getColumns().add(colGenera);

    TableColumn<Change, String> colSpecificEpithet = new TableColumn<>("Specific epithets");
    colSpecificEpithet.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(String
                    .join(", ", features.getValue().getAllNames().stream().map(n -> n.getSpecificEpithet())
                            .filter(s -> s != null).distinct().sorted().collect(Collectors.toList()))));
    tv.getColumns().add(colSpecificEpithet);

    // The infraspecific string.
    TableColumn<Change, String> colInfraspecificEpithet = new TableColumn<>("Infraspecific epithets");
    colInfraspecificEpithet.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    String.join(", ",
                            features.getValue().getAllNames().stream()
                                    .map(n -> n.getInfraspecificEpithetsAsString()).filter(s -> s != null)
                                    .distinct().sorted().collect(Collectors.toList()))));
    tv.getColumns().add(colInfraspecificEpithet);

    // The very last epithet of all
    TableColumn<Change, String> colTerminalEpithet = new TableColumn<>("Terminal epithet");
    colTerminalEpithet.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    String.join(", ", features.getValue().getAllNames().stream().map(n -> {
                        List<Name.InfraspecificEpithet> infraspecificEpithets = n.getInfraspecificEpithets();
                        if (!infraspecificEpithets.isEmpty()) {
                            return infraspecificEpithets.get(infraspecificEpithets.size() - 1).getValue();
                        } else {
                            return n.getSpecificEpithet();
                        }
                    }).filter(s -> s != null).distinct().sorted().collect(Collectors.toList()))));
    tv.getColumns().add(colTerminalEpithet);

    // Properties
    TableColumn<Change, String> colProperties = new TableColumn<>("Properties");
    colProperties.setCellValueFactory(
            (TableColumn.CellDataFeatures<Change, String> features) -> new ReadOnlyStringWrapper(
                    features.getValue().getProperties().entrySet().stream()
                            .map(entry -> entry.getKey() + ": " + entry.getValue()).sorted()
                            .collect(Collectors.joining("; "))));
    tv.getColumns().add(colProperties);

    fillTableWithChanges(tv, tp);

    // When someone selects a cell in the Table, try to select the appropriate data in the
    // additional data view.
    tv.getSelectionModel().getSelectedItems().addListener((ListChangeListener<Change>) lcl -> {
        AdditionalData aData = additionalDataCombobox.getSelectionModel().getSelectedItem();

        if (aData != null) {
            aData.onSelectChange(tv.getSelectionModel().getSelectedItems());
        }
    });

    // Create a right-click menu for table rows.
    changesTableView.setRowFactory(table -> {
        TableRow<Change> row = new TableRow<>();

        row.setOnContextMenuRequested(event -> {
            if (row.isEmpty())
                return;

            // We don't currently use the clicked change, since currently all options
            // change *all* the selected changes, but this may change in the future.
            Change change = row.getItem();

            ContextMenu changeMenu = new ContextMenu();

            Menu searchForName = new Menu("Search for name");
            searchForName.getItems().addAll(
                    change.getAllNames().stream().sorted().map(n -> createMenuItem(n.getFullName(), action -> {
                        datasetView.getProjectView().openDetailedView(n);
                    })).collect(Collectors.toList()));
            changeMenu.getItems().add(searchForName);
            changeMenu.getItems().add(new SeparatorMenuItem());

            changeMenu.getItems().add(createMenuItem("Edit note", action -> {
                List<Change> changes = new ArrayList<>(changesTableView.getSelectionModel().getSelectedItems());

                String combinedNotes = changes.stream().map(ch -> ch.getNote().orElse("").trim()).distinct()
                        .collect(Collectors.joining("\n")).trim();

                Optional<String> result = askUserForTextArea(
                        "Modify the note for these " + changes.size() + " changes:", combinedNotes);

                if (result.isPresent()) {
                    String note = result.get().trim();
                    LOGGER.info("Using 'Edit note' to set note to '" + note + "' on changes " + changes);
                    changes.forEach(ch -> ch.noteProperty().set(note));
                }
            }));
            changeMenu.getItems().add(new SeparatorMenuItem());

            // Create a submenu for tags and urls.
            String note = change.noteProperty().get();

            Menu removeTags = new Menu("Tags");
            removeTags.getItems().addAll(change.getTags().stream().sorted()
                    .map(tag -> new MenuItem(tag.getName())).collect(Collectors.toList()));

            Menu lookupURLs = new Menu("Lookup URL");
            change.getURIs().stream().sorted().map(uri -> {
                return createMenuItem(uri.toString(), evt -> {
                    try {
                        Desktop.getDesktop().browse(uri);
                    } catch (IOException ex) {
                        LOGGER.warning("Could not open URL '" + uri + "': " + ex);
                    }
                });
            }).forEach(mi -> lookupURLs.getItems().add(mi));
            changeMenu.getItems().add(lookupURLs);

            changeMenu.getItems().add(new SeparatorMenuItem());
            changeMenu.getItems().add(createMenuItem("Prepend text to all notes", action -> {
                List<Change> changes = new ArrayList<>(changesTableView.getSelectionModel().getSelectedItems());

                Optional<String> result = askUserForTextField(
                        "Enter tags to prepend to notes in " + changes.size() + " changes:");

                if (result.isPresent()) {
                    String tags = result.get().trim();
                    changes.forEach(ch -> {
                        String prevValue = change.getNote().orElse("").trim();

                        LOGGER.info("Prepending tags '" + tags + "' to previous value '" + prevValue
                                + "' for change " + ch);

                        ch.noteProperty().set((tags + " " + prevValue).trim());
                    });
                }
            }));
            changeMenu.getItems().add(createMenuItem("Append text to all notes", action -> {
                List<Change> changes = new ArrayList<>(changesTableView.getSelectionModel().getSelectedItems());
                Optional<String> result = askUserForTextField(
                        "Enter tags to append to notes in " + changes.size() + " changes:");

                if (result.isPresent()) {
                    String tags = result.get().trim();
                    changes.forEach(ch -> {
                        String prevValue = ch.getNote().orElse("").trim();

                        LOGGER.info("Appending tags '" + tags + "' to previous value '" + prevValue
                                + "' for change " + ch);

                        ch.noteProperty().setValue((prevValue + " " + tags).trim());
                    });
                }
            }));

            changeMenu.show(datasetView.getScene().getWindow(), event.getScreenX(), event.getScreenY());

        });

        return row;
    });

    LOGGER.info("setupTableWithChanges() completed");
}

From source file:org.wallride.service.PageService.java

@CacheEvict(value = WallRideCacheConfiguration.PAGE_CACHE, allEntries = true)
public Page createPage(PageCreateRequest request, Post.Status status, AuthorizedUser authorizedUser) {
    LocalDateTime now = LocalDateTime.now();

    String code = request.getCode();
    if (code == null) {
        try {/*from   w ww .j av a 2 s  . c o  m*/
            code = new CodeFormatter().parse(request.getTitle(), LocaleContextHolder.getLocale());
        } catch (ParseException e) {
            throw new ServiceException(e);
        }
    }
    if (!StringUtils.hasText(code)) {
        if (!status.equals(Post.Status.DRAFT)) {
            throw new EmptyCodeException();
        }
    }

    if (!status.equals(Post.Status.DRAFT)) {
        Post duplicate = postRepository.findOneByCodeAndLanguage(code, request.getLanguage());
        if (duplicate != null) {
            throw new DuplicateCodeException(code);
        }
    }

    Page page = new Page();

    if (!status.equals(Post.Status.DRAFT)) {
        page.setCode(code);
        page.setDraftedCode(null);
    } else {
        page.setCode(null);
        page.setDraftedCode(code);
    }

    Page parent = (request.getParentId() != null)
            ? pageRepository.findOneByIdAndLanguage(request.getParentId(), request.getLanguage())
            : null;
    int rgt = 0;
    if (parent == null) {
        rgt = pageRepository.findMaxRgt();
        rgt++;
    } else {
        rgt = parent.getRgt();
        pageRepository.unshiftRgt(rgt);
        pageRepository.unshiftLft(rgt);
    }

    page.setParent(parent);

    Media cover = null;
    if (request.getCoverId() != null) {
        cover = entityManager.getReference(Media.class, request.getCoverId());
    }
    page.setCover(cover);
    page.setTitle(request.getTitle());
    page.setBody(request.getBody());

    page.setAuthor(entityManager.getReference(User.class, authorizedUser.getId()));

    LocalDateTime date = request.getDate();
    if (Post.Status.PUBLISHED.equals(status)) {
        if (date == null) {
            date = now;
        } else if (date.isAfter(now)) {
            status = Post.Status.SCHEDULED;
        }
    }
    page.setDate(date);
    page.setStatus(status);
    page.setLanguage(request.getLanguage());

    page.getCategories().clear();
    SortedSet<Category> categories = new TreeSet<>();
    for (long categoryId : request.getCategoryIds()) {
        categories.add(entityManager.getReference(Category.class, categoryId));
    }
    page.setCategories(categories);

    page.getTags().clear();
    Set<String> tagNames = StringUtils.commaDelimitedListToSet(request.getTags());
    if (!CollectionUtils.isEmpty(tagNames)) {
        for (String tagName : tagNames) {
            Tag tag = tagRepository.findOneForUpdateByNameAndLanguage(tagName, request.getLanguage());
            if (tag == null) {
                tag = new Tag();
                tag.setName(tagName);
                tag.setLanguage(request.getLanguage());
                page.setCreatedAt(now);
                page.setCreatedBy(authorizedUser.toString());
                page.setUpdatedAt(now);
                page.setUpdatedBy(authorizedUser.toString());
                tag = tagRepository.saveAndFlush(tag);
            }
            page.getTags().add(tag);
        }
    }

    page.getRelatedPosts().clear();
    Set<Post> relatedPosts = new HashSet<>();
    for (long relatedId : request.getRelatedPostIds()) {
        relatedPosts.add(entityManager.getReference(Post.class, relatedId));
    }
    page.setRelatedToPosts(relatedPosts);

    Seo seo = new Seo();
    seo.setTitle(request.getSeoTitle());
    seo.setDescription(request.getSeoDescription());
    seo.setKeywords(request.getSeoKeywords());
    page.setSeo(seo);

    page.setLft(rgt);
    page.setRgt(rgt + 1);

    List<Media> medias = new ArrayList<>();
    if (StringUtils.hasText(request.getBody())) {
        //         Blog blog = blogService.getBlogById(Blog.DEFAULT_ID);
        String mediaUrlPrefix = wallRideProperties.getMediaUrlPrefix();
        Pattern mediaUrlPattern = Pattern.compile(String.format("%s([0-9a-zA-Z\\-]+)", mediaUrlPrefix));
        Matcher mediaUrlMatcher = mediaUrlPattern.matcher(request.getBody());
        while (mediaUrlMatcher.find()) {
            Media media = mediaRepository.findOneById(mediaUrlMatcher.group(1));
            medias.add(media);
        }
    }
    page.setMedias(medias);

    page.setCreatedAt(now);
    page.setCreatedBy(authorizedUser.toString());
    page.setUpdatedAt(now);
    page.setUpdatedBy(authorizedUser.toString());

    page.getCustomFieldValues().clear();
    if (!CollectionUtils.isEmpty(request.getCustomFieldValues())) {
        for (CustomFieldValueEditForm valueForm : request.getCustomFieldValues()) {
            CustomFieldValue value = new CustomFieldValue();
            value.setCustomField(entityManager.getReference(CustomField.class, valueForm.getCustomFieldId()));
            value.setPost(page);
            if (valueForm.getFieldType().equals(CustomField.FieldType.CHECKBOX)) {
                if (!ArrayUtils.isEmpty(valueForm.getTextValues())) {
                    value.setTextValue(String.join(",", valueForm.getTextValues()));
                } else {
                    value.setTextValue(null);
                }
            } else {
                value.setTextValue(valueForm.getTextValue());
            }
            value.setStringValue(valueForm.getStringValue());
            value.setNumberValue(valueForm.getNumberValue());
            value.setDateValue(valueForm.getDateValue());
            value.setDatetimeValue(valueForm.getDatetimeValue());
            if (!value.isEmpty()) {
                page.getCustomFieldValues().add(value);
            }
        }
    }

    return pageRepository.save(page);
}

From source file:org.createnet.raptor.db.mapdb.MapDBConnection.java

protected String getIndexKeyVal(List<String> keys, Record r) {
    String[] arrKeys = new String[keys.size()];
    arrKeys = keys.toArray(arrKeys);//from w  ww . j a  va2  s .  c o  m
    Arrays.sort(arrKeys);
    String[] keyVal = new String[arrKeys.length];
    int i = 0;
    for (String arrKey : arrKeys) {
        if (!r.content.has(arrKey)) {
            logger.debug("Missing record key {} for record {}", arrKey, r.id);
            throw new Storage.StorageException("Cannot index record, missing key " + arrKey);
        }
        keyVal[i] = r.content.get(arrKey).asText();
        i++;
    }

    return String.join(keySeparator, keyVal);
}

From source file:com.uber.hoodie.hive.HoodieHiveClient.java

/**
 * Iterate over the storage partitions and find if there are any new partitions that need
 * to be added or updated. Generate a list of PartitionEvent based on the changes required.
 *//* w  w  w  .j  av a 2s .co m*/
List<PartitionEvent> getPartitionEvents(List<Partition> tablePartitions,
        List<String> partitionStoragePartitions) {
    Map<String, String> paths = Maps.newHashMap();
    for (Partition tablePartition : tablePartitions) {
        List<String> hivePartitionValues = tablePartition.getValues();
        Collections.sort(hivePartitionValues);
        String fullTablePartitionPath = Path
                .getPathWithoutSchemeAndAuthority(new Path(tablePartition.getSd().getLocation())).toUri()
                .getPath();
        paths.put(String.join(", ", hivePartitionValues), fullTablePartitionPath);
    }

    List<PartitionEvent> events = Lists.newArrayList();
    for (String storagePartition : partitionStoragePartitions) {
        String fullStoragePartitionPath = new Path(syncConfig.basePath, storagePartition).toString();
        // Check if the partition values or if hdfs path is the same
        List<String> storagePartitionValues = partitionValueExtractor
                .extractPartitionValuesInPath(storagePartition);
        Collections.sort(storagePartitionValues);
        String storageValue = String.join(", ", storagePartitionValues);
        if (!paths.containsKey(storageValue)) {
            events.add(PartitionEvent.newPartitionAddEvent(storagePartition));
        } else if (!paths.get(storageValue).equals(fullStoragePartitionPath)) {
            events.add(PartitionEvent.newPartitionUpdateEvent(storagePartition));
        }
    }
    return events;
}

From source file:com.caricah.iotracah.datastore.ignitecache.internal.impl.SubscriptionFilterHandler.java

public Observable<IotSubscriptionFilter> getTopicFilterTree(String partition,
        List<String> topicFilterTreeRoute) {

    return Observable.create(observer -> {

        List<Long> collectingParentIdList = new ArrayList<>();

        collectingParentIdList.add(0l);/*w ww . j  ava  2  s .c o  m*/

        List<String> growingTitles = new ArrayList<>();

        ListIterator<String> pathIterator = topicFilterTreeRoute.listIterator();

        try {

            while (pathIterator.hasNext()) {

                String topicPart = pathIterator.next();

                log.debug(" getTopicFilterTree : current path in tree is : {}", topicPart);

                growingTitles.add(topicPart);

                List<Long> parentIdList = new ArrayList<>(collectingParentIdList);
                collectingParentIdList.clear();

                for (Long parentId : parentIdList) {

                    log.debug(" getTopicFilterTree : Dealing with parent id : {} and titles is {}", parentId,
                            growingTitles);

                    if (Constant.MULTI_LEVEL_WILDCARD.equals(topicPart)) {

                        getMultiLevelWildCard(observer, partition, parentId);
                    } else if (Constant.SINGLE_LEVEL_WILDCARD.equals(topicPart)) {

                        String query = "partitionId = ? AND parentId = ? ";
                        Object[] params = { partition, parentId };

                        getByQuery(IotSubscriptionFilter.class, query, params).toBlocking()
                                .forEach(subscriptionFilter -> {

                                    log.debug(" getTopicFilterTree : Found matching single level filter : {}",
                                            subscriptionFilter);

                                    if (pathIterator.hasNext()) {
                                        collectingParentIdList.add(subscriptionFilter.getId());

                                    } else {
                                        observer.onNext(subscriptionFilter);
                                    }

                                });

                    } else {

                        String query = "partitionId = ? AND parentId = ? AND name = ? ";

                        String joinedTopicName = String.join(Constant.PATH_SEPARATOR, growingTitles);

                        Object[] params = new Object[] { partition, parentId, joinedTopicName };

                        getByQuery(IotSubscriptionFilter.class, query, params).toBlocking()
                                .forEach(subscriptionFilter -> {

                                    log.debug(" getTopicFilterTree : Found matching point filter : {}",
                                            subscriptionFilter);

                                    if (pathIterator.hasNext()) {
                                        collectingParentIdList.add(subscriptionFilter.getId());
                                    } else {
                                        observer.onNext(subscriptionFilter);
                                    }

                                });

                    }
                }

            }

            observer.onCompleted();

        } catch (Exception e) {
            observer.onError(e);
        }

    });

}

From source file:io.syndesis.runtime.action.DynamicActionDefinitionITCase.java

private static String read(final String path) {
    try {/*from   w  ww.j av  a  2  s .com*/
        return String.join("",
                Files.readAllLines(Paths.get(DynamicActionDefinitionITCase.class.getResource(path).toURI())));
    } catch (IOException | URISyntaxException e) {
        throw new IllegalArgumentException("Unable to read from path: " + path, e);
    }
}