Search in sources :

Example 6 with LocalizedString

use of org.obiba.mica.core.domain.LocalizedString in project mica2 by obiba.

the class CollectedDatasetServiceTest method buildStudyDataset.

private StudyDataset buildStudyDataset() {
    StudyDataset ds = new StudyDataset();
    StudyTable st = new StudyTable();
    st.setProject("proj");
    st.setTable("tab");
    ds.setStudyTable(st);
    ds.setName(new LocalizedString(Locale.CANADA, "test"));
    return ds;
}
Also used : StudyTable(org.obiba.mica.core.domain.StudyTable) LocalizedString(org.obiba.mica.core.domain.LocalizedString) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Example 7 with LocalizedString

use of org.obiba.mica.core.domain.LocalizedString in project mica2 by obiba.

the class HarmonizedDatasetServiceTest method buildHarmonizationDataset.

private HarmonizationDataset buildHarmonizationDataset(String id, StudyTable... studyTables) {
    HarmonizationDataset ds = new HarmonizationDataset();
    for (StudyTable s : studyTables) {
        ds.addStudyTable(s);
    }
    ds.setId(id);
    ds.setName(new LocalizedString(Locale.CANADA, "dataset" + id));
    return ds;
}
Also used : StudyTable(org.obiba.mica.core.domain.StudyTable) LocalizedString(org.obiba.mica.core.domain.LocalizedString) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Example 8 with LocalizedString

use of org.obiba.mica.core.domain.LocalizedString in project mica2 by obiba.

the class DataAccessResource method getDataAccessForm.

@GET
@Path("/form")
@Timed
public Mica.DataAccessFormDto getDataAccessForm(@QueryParam("lang") String lang) {
    Optional<DataAccessForm> d = dataAccessFormService.find();
    if (!d.isPresent())
        throw NoSuchDataAccessFormException.withDefaultMessage();
    DataAccessForm dataAccessForm = d.get();
    Mica.DataAccessFormDto.Builder builder = Mica.DataAccessFormDto.newBuilder(dtos.asDto(dataAccessForm)).clearProperties().clearPdfTemplates();
    String langTag = !Strings.isNullOrEmpty(lang) ? Locale.forLanguageTag(lang).toLanguageTag() : LanguageTag.UNDETERMINED;
    Map<String, LocalizedString> properties = dataAccessForm.getProperties().entrySet().stream().map(e -> Maps.immutableEntry(e.getKey(), new LocalizedString().forLanguageTag(langTag, e.getValue().get(langTag)))).collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
    builder.addAllProperties(dtos.asDtoList(properties));
    return builder.build();
}
Also used : DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm) LocalizedString(org.obiba.mica.core.domain.LocalizedString) FileResource(org.obiba.mica.file.rest.FileResource) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) Maps(com.google.common.collect.Maps) NoSuchDataAccessFormException(org.obiba.mica.micaConfig.NoSuchDataAccessFormException) Scope(org.springframework.context.annotation.Scope) Inject(javax.inject.Inject) Timed(com.codahale.metrics.annotation.Timed) Strings(com.google.common.base.Strings) Component(org.springframework.stereotype.Component) QueryParam(javax.ws.rs.QueryParam) LanguageTag(sun.util.locale.LanguageTag) Collectors.toMap(java.util.stream.Collectors.toMap) DataAccessFormService(org.obiba.mica.micaConfig.service.DataAccessFormService) Locale(java.util.Locale) Map(java.util.Map) Mica(org.obiba.mica.web.model.Mica) Optional(java.util.Optional) RequiresAuthentication(org.apache.shiro.authz.annotation.RequiresAuthentication) Dtos(org.obiba.mica.web.model.Dtos) LocalizedString(org.obiba.mica.core.domain.LocalizedString) LocalizedString(org.obiba.mica.core.domain.LocalizedString) DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 9 with LocalizedString

use of org.obiba.mica.core.domain.LocalizedString in project mica2 by obiba.

the class NetworkService method getNextId.

private String getNextId(LocalizedString suggested) {
    if (suggested == null)
        return null;
    String prefix = suggested.asUrlSafeString().toLowerCase();
    if (Strings.isNullOrEmpty(prefix))
        return null;
    String next = prefix;
    try {
        findById(next);
        for (int i = 1; i <= 1000; i++) {
            next = prefix + "-" + i;
            findById(next);
        }
        return null;
    } catch (NoSuchNetworkException e) {
        return next;
    }
}
Also used : NoSuchNetworkException(org.obiba.mica.network.NoSuchNetworkException) LocalizedString(org.obiba.mica.core.domain.LocalizedString)

Example 10 with LocalizedString

use of org.obiba.mica.core.domain.LocalizedString in project mica2 by obiba.

the class ConfigurationTaxonomyMetaDataProvider method populateMetadataMap.

private Map<String, LocalizedMetaData> populateMetadataMap(Vocabulary vocabulary) {
    Map<String, LocalizedMetaData> metaData = Maps.newHashMap();
    if (vocabulary != null && vocabulary.hasTerms()) {
        vocabulary.getTerms().forEach(t -> {
            LocalizedString title = new LocalizedString();
            title.putAll(t.getTitle());
            LocalizedString description = new LocalizedString();
            description.putAll(t.getDescription());
            String className = t.getAttributeValue("className");
            if (Strings.isNullOrEmpty(className)) {
                className = t.getClass().getSimpleName();
            }
            LocalizedMetaData md = new LocalizedMetaData(title, description, className, t.getAttributeValue("start"), t.getAttributeValue("end"));
            metaData.put(t.getName(), md);
            metaData.put(t.getName().toLowerCase(), md);
        });
    }
    return metaData;
}
Also used : LocalizedString(org.obiba.mica.core.domain.LocalizedString) LocalizedString(org.obiba.mica.core.domain.LocalizedString)

Aggregations

LocalizedString (org.obiba.mica.core.domain.LocalizedString)11 StudyTable (org.obiba.mica.core.domain.StudyTable)2 Timed (com.codahale.metrics.annotation.Timed)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Strings (com.google.common.base.Strings)1 Maps (com.google.common.collect.Maps)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Nullable (javax.annotation.Nullable)1 Inject (javax.inject.Inject)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 QueryParam (javax.ws.rs.QueryParam)1 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)1 NoSuchDatasetException (org.obiba.mica.dataset.NoSuchDatasetException)1 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)1 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)1 FileResource (org.obiba.mica.file.rest.FileResource)1