Search in sources :

Example 51 with Tags

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

the class BackendUserTagResourceTest method setUpTagExpectations.

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

Example 52 with Tags

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

the class TagListModel method tagToModel.

public TagModel tagToModel(Tags tag) {
    EntityModel<String> tempVar = new EntityModel<>();
    tempVar.setEntity(tag.getTagName());
    EntityModel<String> name = tempVar;
    EntityModel<String> tempVar2 = new EntityModel<>();
    tempVar2.setEntity(tag.getDescription());
    EntityModel<String> description = tempVar2;
    ArrayList<TagModel> children = new ArrayList<>();
    for (Tags a : tag.getChildren()) {
        children.add(tagToModel(a));
    }
    TagModel model = new TagModel();
    model.setId(tag.getTagId());
    model.setName(name);
    model.setDescription(description);
    model.setType((tag.getIsReadonly() == null ? false : tag.getIsReadonly()) ? TagModelType.ReadOnly : TagModelType.Regular);
    model.setSelection(false);
    model.setParentId(tag.getParentId() == null ? Guid.Empty : tag.getParentId());
    model.setChildren(children);
    for (TagModel child : children) {
        child.setParent(model);
    }
    model.getSelectionChangedEvent().addListener(this);
    return model;
}
Also used : EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) Tags(org.ovirt.engine.core.common.businessentities.Tags)

Example 53 with Tags

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

the class TagListModel method onSave.

public void onSave() {
    TagModel model = (TagModel) getWindow();
    if (model.getProgress() != null) {
        return;
    }
    if (!model.validate()) {
        return;
    }
    Tags tempVar = new Tags();
    tempVar.setTagId(model.getIsNew() ? Guid.Empty : getSelectedItem().getId());
    tempVar.setParentId(model.getIsNew() ? getSelectedItem().getId() : getSelectedItem().getParentId());
    tempVar.setTagName(model.getName().getEntity());
    tempVar.setDescription(model.getDescription().getEntity());
    Tags tag = tempVar;
    model.startProgress();
    Frontend.getInstance().runAction(model.getIsNew() ? ActionType.AddTag : ActionType.UpdateTag, new TagsOperationParameters(tag), result -> {
        TagListModel localModel = (TagListModel) result.getState();
        localModel.postOnSave(result.getReturnValue());
    }, this);
}
Also used : TagsOperationParameters(org.ovirt.engine.core.common.action.TagsOperationParameters) Tags(org.ovirt.engine.core.common.businessentities.Tags)

Example 54 with Tags

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

the class TagsDirectorTest method testGetByName.

@Test
public void testGetByName() {
    Tags tag = createTag("tag1", "desc1");
    tagsDirector.addTag(tag);
    Tags fromTagsDirector = tagsDirector.getTagByTagName("tag1");
    assertNotNull(fromTagsDirector);
    assertEquals(tag, fromTagsDirector);
}
Also used : Tags(org.ovirt.engine.core.common.businessentities.Tags) Test(org.junit.Test)

Example 55 with Tags

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

the class TagsDirectorTest method testIsNonDirectDescetor.

@Test
public void testIsNonDirectDescetor() {
    Tags tag1 = createTag("tag1", "desc1");
    Tags tag2 = createTag("tag2", "desc2");
    Tags tag3 = createTag("tag3", "desc3");
    tagsDirector.addTag(tag1);
    tagsDirector.addTag(tag2);
    tagsDirector.addTag(tag3);
    tagsDirector.moveTag(tag3.getTagId(), tag1.getTagId());
    tagsDirector.moveTag(tag2.getTagId(), tag3.getTagId());
    assertTrue(tagsDirector.isTagDescestorOfTag(tag1.getTagId(), tag2.getTagId()));
}
Also used : Tags(org.ovirt.engine.core.common.businessentities.Tags) Test(org.junit.Test)

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