Search in sources :

Example 21 with Tags

use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.

the class TagsDirector method init.

/**
 * In memory tree initialized during initialization
 */
@PostConstruct
protected void init() {
    log.info("Start initializing {}", getClass().getSimpleName());
    tagsMapByID.clear();
    tagsMapByName.clear();
    Tags root = new Tags("root", null, true, ROOT_TAG_ID, "root");
    addTagToHash(root);
    addChildren(root);
    log.info("Finished initializing {}", getClass().getSimpleName());
}
Also used : Tags(org.ovirt.engine.core.common.businessentities.Tags) PostConstruct(javax.annotation.PostConstruct)

Example 22 with Tags

use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.

the class TagMapper method map.

@Mapping(from = Tag.class, to = Tags.class)
public static Tags map(Tag model, Tags template) {
    Tags entity = template != null ? template : new Tags();
    entity.setParentId(parent(model, entity.getParentId()));
    if (model.isSetId()) {
        entity.setTagId(GuidUtils.asGuid(model.getId()));
    }
    if (model.isSetName()) {
        entity.setTagName(model.getName());
    }
    if (model.isSetDescription()) {
        entity.setDescription(model.getDescription());
    }
    return entity;
}
Also used : Tags(org.ovirt.engine.core.common.businessentities.Tags)

Example 23 with Tags

use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.

the class BatchProcedureCallTest method testBatch.

@Test
public void testBatch() {
    List<Tags> tags = dao.getAll();
    for (Tags tag : tags) {
        dao.remove(tag.getTagId());
    }
    List<Tags> data = new ArrayList<>();
    data.add(new Tags("a", Guid.Empty, true, Guid.newGuid(), "a"));
    data.add(new Tags("b", Guid.Empty, true, Guid.newGuid(), "b"));
    List<MapSqlParameterSource> executions = data.stream().map(this::getParamsSource).collect(Collectors.toList());
    jdbcCallsHandler.executeStoredProcAsBatch("Inserttags", executions);
    List<Tags> tagsAfterInsert = dao.getAll();
    assertNotNull(tagsAfterInsert);
    assertEquals(data.size(), tagsAfterInsert.size());
    assertTrue(data.containsAll(tagsAfterInsert));
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) CustomMapSqlParameterSource(org.ovirt.engine.core.dal.dbbroker.CustomMapSqlParameterSource) ArrayList(java.util.ArrayList) Tags(org.ovirt.engine.core.common.businessentities.Tags) Test(org.junit.Test)

Example 24 with Tags

use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.

the class BackendTemplateTagResourceTest method setUpTagsExpectations.

private List<Tags> setUpTagsExpectations() {
    List<Tags> tags = new ArrayList<>();
    for (int i = 0; i < GUIDS.length; i++) {
        Tags tag = setUpTagExpectations(GUIDS[i]);
        tags.add(tag);
    }
    return tags;
}
Also used : ArrayList(java.util.ArrayList) Tags(org.ovirt.engine.core.common.businessentities.Tags)

Example 25 with Tags

use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.

the class BackendTemplateTagResourceTest method setUpTagExpectations.

private Tags setUpTagExpectations(Guid tagId) {
    Tags tags = mock(Tags.class);
    when(tags.getTagId()).thenReturn(tagId);
    when(tags.getParentId()).thenReturn(TEMPLATE_ID);
    return tags;
}
Also used : Tags(org.ovirt.engine.core.common.businessentities.Tags)

Aggregations

Tags (org.ovirt.engine.core.common.businessentities.Tags)68 Test (org.junit.Test)34 ArrayList (java.util.ArrayList)8 Guid (org.ovirt.engine.core.compat.Guid)5 HashSet (java.util.HashSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Before (org.junit.Before)2 TagsTemplateMap (org.ovirt.engine.core.common.businessentities.TagsTemplateMap)2 TagsVdsMap (org.ovirt.engine.core.common.businessentities.TagsVdsMap)2 TagsVmMap (org.ovirt.engine.core.common.businessentities.TagsVmMap)2 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)2 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 Date (java.util.Date)1 List (java.util.List)1 PostConstruct (javax.annotation.PostConstruct)1 Named (javax.inject.Named)1 Singleton (javax.inject.Singleton)1 Response (javax.ws.rs.core.Response)1 Tag (org.ovirt.engine.api.model.Tag)1