Example usage for org.apache.wicket.util.string StringValue toString

List of usage examples for org.apache.wicket.util.string StringValue toString

Introduction

In this page you can find the example usage for org.apache.wicket.util.string StringValue toString.

Prototype

@Override
public final String toString() 

Source Link

Usage

From source file:com.romeikat.datamessie.core.base.ui.page.AbstractDocumentsFilterPage.java

License:Open Source License

private Collection<Long> parseSourceTypeIds(final StringValue stringValue) {
    List<Long> sourceTypeIds = null;
    try {/*w  w w.ja  v a2s  . c o m*/
        sourceTypeIds = new ArrayList<Long>();
        final String[] sourceTypeIdStrings = StringUtils.split(stringValue.toString(), ",");
        for (final String sourceTypeIdString : sourceTypeIdStrings) {
            final long sourceTypeId = Long.parseLong(sourceTypeIdString);
            sourceTypeIds.add(sourceTypeId);
        }
    } catch (final Exception e) {
        sourceTypeIds = null;
    }
    return sourceTypeIds;
}

From source file:com.romeikat.datamessie.core.base.ui.page.AbstractDocumentsFilterPage.java

License:Open Source License

private Collection<DocumentProcessingState> parseStates(final StringValue stringValue) {
    List<DocumentProcessingState> states = null;
    try {//from ww w .  j av  a  2s  .  c  o  m
        states = new ArrayList<DocumentProcessingState>();
        final DocumentProcessingState[] allStates = DocumentProcessingState.values();
        final String[] stateOrdinalStrings = StringUtils.split(stringValue.toString(), ",");
        for (final String stateOrdinalString : stateOrdinalStrings) {
            final int stateOrdinal = Integer.parseInt(stateOrdinalString);
            final DocumentProcessingState state = allStates[stateOrdinal];
            states.add(state);
        }
    } catch (final Exception e) {
        states = null;
    }
    return states;
}

From source file:com.romeikat.datamessie.core.base.ui.page.AbstractDocumentsFilterPage.java

License:Open Source License

private LocalDate parseLocalDate(final StringValue stringValue) {
    final LocalDate today = LocalDate.now();
    // No date corresponds to today
    if (stringValue == null) {
        return today;
    }//from ww  w . j  a  v  a  2s .  c o  m
    // 0 corresponds to no date
    if (stringValue.toString().equals("0")) {
        return null;
    }
    // Negative numbers correspond to number of days from today in the past
    try {
        final int numberOfDays = Integer.parseInt(stringValue.toString());
        if (numberOfDays < 0) {
            final LocalDate localDate = today.plusDays(numberOfDays);
            return localDate;
        }
    } catch (final NumberFormatException e) {
    }
    // Date pattern
    final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
    try {
        final LocalDate localDate = LocalDate.parse(stringValue.toString(), dateFormatter);
        return localDate;
    } catch (final IllegalArgumentException ex) {
    }
    // Ohterwise, use today
    return today;
}

From source file:cz.muni.exceptions.web.pages.ExceptionDetailPage.java

License:Apache License

private IModel<Ticket> preparePageModel(PageParameters params) {
    StringValue idValue = params.get("ticketId");
    if (idValue.isEmpty()) {
        getSession()//from w w w . j  av a 2 s  .c om
                .error("Ooops!! It's not possible to show ticket detail, because id of ticket wasn't provided");
        throw new RestartResponseException(ExceptionsPage.class);
    }

    Long id = null;
    try {
        id = Long.parseLong(idValue.toString());
        Ticket ticket = ticketService.getTicket(id);
        return new CompoundPropertyModel<Ticket>(ticket);
    } catch (NumberFormatException ex) {
        getSession().error("Oopps!! Ticket does not exists.");
        throw new RestartResponseException(ExceptionsPage.class);
    } catch (Exception ex) {
        getSession().error("Ooppss!! We have some technical difficulties. Please try later.");
        return Model.of();
    }
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.account.ChangePasswordPage.java

License:Apache License

public ChangePasswordPage(PageParameters parameters) {

    StringValue value = parameters.get(PARAM_ID);
    if (!value.isNull() && !value.isEmpty() && value.toString().equals(PARAM_ID)) {
        add(new Label("headTitle", ResourceUtils.getModel("pageTitle.changesWereMade")));
        setupComponents(false);/*w  w  w .ja v  a  2s  .  c o  m*/
    } else
        throw new RestartResponseAtInterceptPageException(AccountOverViewPage.class);

}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.experiments.ListExperimentsPage.java

License:Apache License

private String parseParameters(PageParameters parameters) {

    StringValue value = parameters.get(BasePage.DEFAULT_PARAM_ID);
    if (value.isNull() || value.isEmpty())
        throw new RestartResponseAtInterceptPageException(EEGDataBaseApplication.get().getHomePage());
    return value.toString();
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.history.HistoryPage.java

License:Apache License

public HistoryPage(PageParameters parameters) {

    StringValue value = parseParameters(parameters);

    ChoiceHistory choice = ChoiceHistory.DAILY;

    try {/*w w  w  . j  a v a2s. co  m*/
        choice = ChoiceHistory.valueOf(ChoiceHistory.class, value.toString());
    } catch (IllegalArgumentException e) {
        throw new RestartResponseAtInterceptPageException(HistoryPage.class);
    }

    addComponents(choice);
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.search.SearchFacets.java

License:Apache License

public SearchFacets(String id, StringValue searchStringValue, final ResultCategory resultCategory) {
    super(id);/*from w  w w  .  j  a va 2  s.  c  om*/
    this.searchString = searchStringValue.toString();
    this.resultCategory = resultCategory;
    categories = new ArrayList<FacetCategory>();

    Map<String, Long> facets = searchService.getCategoryFacets(this.searchString);
    for (Map.Entry<String, Long> entry : facets.entrySet()) {
        if (entry.getValue() > 0) {
            FacetCategory facetCategory = new FacetCategory(entry.getKey(), entry.getValue());
            categories.add(facetCategory);
        }
    }

    Collections.sort(categories);

    add(new ListView<FacetCategory>("categoryList", categories) {
        @Override
        protected void populateItem(ListItem<FacetCategory> category) {
            PageParameters pageParameters = new PageParameters();
            pageParameters.add("searchString", searchString);
            pageParameters.add("category", category.getModelObject().getName());

            String categoryName = getPropertyForType(category.getModelObject().getName());
            String categoryValue = categoryName + " (" + category.getModelObject().getCount() + ")";
            Link link = new BookmarkablePageLink<Void>("category", SearchPage.class, pageParameters);
            if (resultCategory != null
                    && category.getModelObject().getName().equals(resultCategory.getValue())) {
                link.setEnabled(false);
            }
            category.add(link.add(new Label("categoryName", categoryValue)));
        }
    });
}

From source file:cz.zcu.kiv.eegdatabase.wui.ui.search.SearchResultDataProvider.java

License:Apache License

public SearchResultDataProvider(StringValue searchString, ResultCategory category) {
    Injector.get().inject(this);

    System.out.println(searchString);
    if (searchString.isNull()) {
        this.searchQuery = "";
    } else {/*from  w w w.  j a  va  2 s.  c  o m*/
        this.searchQuery = searchString.toString();
    }

    this.category = category;
}

From source file:de.alpharogroup.wicket.base.util.parameter.PageParametersExtensions.java

License:Apache License

/**
 * Gets the string from the given {@link StringValue} or null if it is null or is empty.
 *
 * @param value/* www  . j  a v  a2 s  . c  om*/
 *            the {@link StringValue}
 * @return the string or null if it is null or is empty.
 */
public static String getString(final StringValue value) {
    if (isNotNullOrEmpty(value)) {
        return value.toString();
    }
    return null;
}