Search in sources :

Example 11 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project ORCID-Source by ORCID.

the class BaseWorkspaceController method getOrcidHash.

@ModelAttribute("orcidIdHash")
String getOrcidHash(HttpServletRequest request) throws Exception {
    HttpSession session = request.getSession(false);
    String hash = session != null ? (String) session.getAttribute(ORCID_ID_HASH) : null;
    if (!PojoUtil.isEmpty(hash)) {
        return hash;
    }
    hash = profileEntityManager.getOrcidHash(getEffectiveUserOrcid());
    if (session != null) {
        request.getSession().setAttribute(ORCID_ID_HASH, hash);
    }
    return hash;
}
Also used : HttpSession(javax.servlet.http.HttpSession) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 12 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project ORCID-Source by ORCID.

the class WorkspaceController method retrieveCurrencyCodesTypesAsMap.

@ModelAttribute("currencyCodeTypes")
public Map<String, String> retrieveCurrencyCodesTypesAsMap() {
    Map<String, String> currencyCodeTypes = new LinkedHashMap<String, String>();
    //Add an empty one
    currencyCodeTypes.put("", "");
    for (Currency currency : Currency.getAvailableCurrencies()) {
        currencyCodeTypes.put(currency.getCurrencyCode(), currency.getCurrencyCode());
    }
    return FunctionsOverCollections.sortMapsByValues(currencyCodeTypes);
}
Also used : Currency(java.util.Currency) LinkedHashMap(java.util.LinkedHashMap) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 13 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project ORCID-Source by ORCID.

the class ResultContainer method retrieveGroupTypes.

@ModelAttribute("groupTypes")
public Map<String, String> retrieveGroupTypes() {
    MemberType[] groupTypes = MemberType.values();
    Map<String, String> groupTypesMap = new TreeMap<String, String>();
    for (MemberType groupType : groupTypes) {
        String key = groupType.value();
        String value = key.replace('-', ' ');
        groupTypesMap.put(key, value);
    }
    return groupTypesMap;
}
Also used : MemberType(org.orcid.jaxb.model.clientgroup.MemberType) TreeMap(java.util.TreeMap) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 14 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project ORCID-Source by ORCID.

the class ManageConsortiumController method retrieveContactRoleTypesAsMap.

@ModelAttribute("contactRoleTypes")
public Map<String, String> retrieveContactRoleTypesAsMap() {
    Map<String, String> map = new LinkedHashMap<>();
    for (ContactRoleType type : ContactRoleType.values()) {
        map.put(type.name(), getMessage(buildInternationalizationKey(ContactRoleType.class, type.name())));
    }
    Map<String, String> sorted = new LinkedHashMap<>();
    // @formatter:off
    map.entrySet().stream().sorted(Map.Entry.<String, String>comparingByValue()).forEachOrdered(x -> sorted.put(x.getKey(), x.getValue()));
    // @formatter:on
    return sorted;
}
Also used : ContactRoleType(org.orcid.core.salesforce.model.ContactRoleType) LinkedHashMap(java.util.LinkedHashMap) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute)

Example 15 with ModelAttribute

use of org.springframework.web.bind.annotation.ModelAttribute in project spring-framework by spring-projects.

the class ErrorsMethodArgumentResolver method getModelAttributeName.

private String getModelAttributeName(MethodParameter parameter) {
    Assert.isTrue(parameter.getParameterIndex() > 0, "Errors argument must be immediately after a model attribute argument.");
    int index = parameter.getParameterIndex() - 1;
    MethodParameter attributeParam = new MethodParameter(parameter.getMethod(), index);
    Class<?> attributeType = attributeParam.getParameterType();
    ResolvableType type = ResolvableType.forMethodParameter(attributeParam);
    ReactiveAdapter adapter = getAdapterRegistry().getAdapter(type.resolve());
    Assert.isNull(adapter, "Errors/BindingResult cannot be used with an async model attribute. " + "Either declare the model attribute without the async wrapper type " + "or handle WebExchangeBindException through the async type.");
    ModelAttribute annot = parameter.getParameterAnnotation(ModelAttribute.class);
    if (annot != null && StringUtils.hasText(annot.value())) {
        return annot.value();
    }
    // TODO: Conventions does not deal with async wrappers
    return ClassUtils.getShortNameAsProperty(attributeType);
}
Also used : ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) MethodParameter(org.springframework.core.MethodParameter) ResolvableType(org.springframework.core.ResolvableType) ReactiveAdapter(org.springframework.core.ReactiveAdapter)

Aggregations

ModelAttribute (org.springframework.web.bind.annotation.ModelAttribute)35 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)15 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 Locale (java.util.Locale)3 DBObject (com.mongodb.DBObject)2 ApiOperation (io.swagger.annotations.ApiOperation)2 Method (java.lang.reflect.Method)2 BigDecimal (java.math.BigDecimal)2 List (java.util.List)2 Valid (javax.validation.Valid)2 MongoConstants (org.devgateway.ocds.persistence.mongo.constants.MongoConstants)2 YearFilterPagingRequest (org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest)2 LoanProductRequest (org.mifos.dto.domain.LoanProductRequest)2 ReportCategoryDto (org.mifos.dto.domain.ReportCategoryDto)2 LoanProductFormDto (org.mifos.dto.screen.LoanProductFormDto)2 InvocableHandlerMethod (org.springframework.web.method.support.InvocableHandlerMethod)2 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BasicDBObject (com.mongodb.BasicDBObject)1