Search in sources :

Example 11 with Tag

use of org.sagebionetworks.bridge.models.Tag in project BridgeServer2 by Sage-Bionetworks.

the class HibernateTagDao method addTag.

@Override
public void addTag(String tagValue) {
    Tag tag = new Tag(tagValue);
    hibernateHelper.executeWithExceptionHandling(tag, (session) -> {
        session.saveOrUpdate(tag);
        return null;
    });
}
Also used : Tag(org.sagebionetworks.bridge.models.Tag)

Example 12 with Tag

use of org.sagebionetworks.bridge.models.Tag in project BridgeServer2 by Sage-Bionetworks.

the class HibernateTagDao method deleteTag.

@Override
public void deleteTag(String tagValue) {
    Tag tag = new Tag(tagValue);
    hibernateHelper.executeWithExceptionHandling(tag, (session) -> {
        session.remove(tag);
        return null;
    });
}
Also used : Tag(org.sagebionetworks.bridge.models.Tag)

Example 13 with Tag

use of org.sagebionetworks.bridge.models.Tag in project BridgeServer2 by Sage-Bionetworks.

the class HibernateTagDao method getTags.

@Override
public Map<String, List<String>> getTags() {
    ListMultimap<String, String> multimap = MultimapBuilder.hashKeys().arrayListValues().build();
    List<Tag> tags = hibernateHelper.queryGet("from Tag", null, null, null, Tag.class);
    for (Tag tag : tags) {
        String[] elements = tag.getValue().split(":", 2);
        if (elements.length == 1) {
            multimap.put("default", elements[0]);
        } else {
            multimap.put(elements[0], elements[1]);
        }
    }
    return Multimaps.asMap(multimap);
}
Also used : Tag(org.sagebionetworks.bridge.models.Tag)

Aggregations

Tag (org.sagebionetworks.bridge.models.Tag)13 Test (org.testng.annotations.Test)9 DeleteEvent (org.hibernate.event.spi.DeleteEvent)2 MergeEvent (org.hibernate.event.spi.MergeEvent)2 PersistEvent (org.hibernate.event.spi.PersistEvent)2 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1 SaveOrUpdateEvent (org.hibernate.event.spi.SaveOrUpdateEvent)1 StatusMessage (org.sagebionetworks.bridge.models.StatusMessage)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1