Search in sources :

Example 1 with TagsVdsMap

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

the class AttachVdsToTagCommand method executeCommand.

@Override
protected void executeCommand() {
    TagsVdsMap map;
    if (getTagId() != null) {
        for (Guid vdsId : getVdsList()) {
            VDS vds = vdsDao.get(vdsId);
            if (tagDao.getTagVdsByTagIdAndByVdsId(getTagId(), vdsId) == null) {
                if (vds != null) {
                    appendCustomCommaSeparatedValue("VdsNames", vds.getName());
                }
                map = new TagsVdsMap(getTagId(), vdsId);
                tagDao.attachVdsToTag(map);
                noActionDone = false;
            } else {
                if (vds != null) {
                    appendCustomCommaSeparatedValue("VdsNamesExists", vds.getName());
                }
            }
        }
    }
    setSucceeded(true);
}
Also used : TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap) VDS(org.ovirt.engine.core.common.businessentities.VDS) Guid(org.ovirt.engine.core.compat.Guid)

Example 2 with TagsVdsMap

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

the class TagDaoTest method testGetTagVdsMap.

@Test
public void testGetTagVdsMap() {
    TagsVdsMap result = dao.getTagVdsByTagIdAndByVdsId(existingVdsTag.getTagId(), existingVdsTag.getVdsId());
    assertNotNull(result);
    assertEqualsTagsVdsMap(existingVdsTag, result);
}
Also used : TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap) Test(org.junit.Test)

Example 3 with TagsVdsMap

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

the class TagDaoTest method testDetachVdsFromTag.

@Test
public void testDetachVdsFromTag() {
    dao.detachVdsFromTag(existingVdsTag.getTagId(), existingVdsTag.getVdsId());
    TagsVdsMap result = dao.getTagVdsByTagIdAndByVdsId(existingVdsTag.getTagId(), existingVdsTag.getVdsId());
    assertNull(result);
}
Also used : TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap) Test(org.junit.Test)

Example 4 with TagsVdsMap

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

the class TagDaoTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    dao = dbFacade.getTagDao();
    existingTag = dao.get(EXISTING_TAG_ID);
    existingTag = dao.get(new Guid("d3ec3e01-ca89-48e1-8b43-a9b38f873b0c"));
    parent = FixturesTool.DATA_CENTER;
    user = new Guid("9bf7c640-b620-456f-a550-0348f366544a");
    vm = EXISTING_VM_ID;
    template = new Guid("77296e00-0cad-4e5a-9299-008a7b6f4355");
    vmPool = new Guid("103cfd1d-18b1-4790-8a0c-1e52621b0076");
    newTag = new Tags();
    newTag.setTagName("newtagname");
    newTag.setIsReadonly(true);
    newTag.setDescription("newtagdescription");
    newTag.setParentId(parent);
    existingUserGroupTag = dao.getTagUserGroupByGroupIdAndByTagId(EXISTING_TAG_ID, EXISTING_GROUP_ID);
    existingUserTag = dao.getTagUserByTagIdAndByuserId(EXISTING_TAG_ID, EXISTING_USER_ID);
    existingVdsTag = dao.getTagVdsByTagIdAndByVdsId(EXISTING_TAG_ID, FixturesTool.VDS_RHEL6_NFS_SPM);
    newVdsTag = new TagsVdsMap(EXISTING_TAG_ID, FixturesTool.HOST_ID);
    existingVmTag = dao.getTagVmByTagIdAndByVmId(EXISTING_TAG_ID, EXISTING_VM_ID);
    existingTemplateTag = dao.getTagTemplateByTagIdAndByTemplateId(EXISTING_TAG_ID, EXISTING_TEMPLATE_ID);
    newVmTag = new TagsVmMap(EXISTING_TAG_ID, FREE_VM_ID);
    newTemplateTag = new TagsTemplateMap(EXISTING_TAG_ID, FREE_TEMPLATE_ID);
}
Also used : TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap) TagsTemplateMap(org.ovirt.engine.core.common.businessentities.TagsTemplateMap) Guid(org.ovirt.engine.core.compat.Guid) Tags(org.ovirt.engine.core.common.businessentities.Tags) Before(org.junit.Before)

Example 5 with TagsVdsMap

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

the class TagDaoImpl method getTagVdsByTagIdAndByVdsId.

@Override
public TagsVdsMap getTagVdsByTagIdAndByVdsId(Guid tagId, Guid vdsId) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("tag_id", tagId).addValue("vds_id", vdsId);
    RowMapper<TagsVdsMap> mapper = (rs, rowNum) -> {
        TagsVdsMap entity = new TagsVdsMap();
        entity.setTagId(getGuidDefaultEmpty(rs, "tag_id"));
        entity.setVdsId(getGuidDefaultEmpty(rs, "vds_id"));
        return entity;
    };
    return getCallsHandler().executeRead("GetTagVdsBytagIdAndByVdsId", mapper, parameterSource);
}
Also used : TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap) Guid(org.ovirt.engine.core.compat.Guid) TagsUserGroupMap(org.ovirt.engine.core.common.businessentities.TagsUserGroupMap) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) Singleton(javax.inject.Singleton) TagsTemplateMap(org.ovirt.engine.core.common.businessentities.TagsTemplateMap) TagsType(org.ovirt.engine.core.common.businessentities.TagsType) SQLException(java.sql.SQLException) List(java.util.List) TagsUserMap(org.ovirt.engine.core.common.businessentities.TagsUserMap) ResultSet(java.sql.ResultSet) Tags(org.ovirt.engine.core.common.businessentities.Tags) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap) RowMapper(org.springframework.jdbc.core.RowMapper) Named(javax.inject.Named) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) TagsVdsMap(org.ovirt.engine.core.common.businessentities.TagsVdsMap)

Aggregations

TagsVdsMap (org.ovirt.engine.core.common.businessentities.TagsVdsMap)6 Test (org.junit.Test)3 Guid (org.ovirt.engine.core.compat.Guid)3 Tags (org.ovirt.engine.core.common.businessentities.Tags)2 TagsTemplateMap (org.ovirt.engine.core.common.businessentities.TagsTemplateMap)2 TagsVmMap (org.ovirt.engine.core.common.businessentities.TagsVmMap)2 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 List (java.util.List)1 Named (javax.inject.Named)1 Singleton (javax.inject.Singleton)1 Before (org.junit.Before)1 TagsType (org.ovirt.engine.core.common.businessentities.TagsType)1 TagsUserGroupMap (org.ovirt.engine.core.common.businessentities.TagsUserGroupMap)1 TagsUserMap (org.ovirt.engine.core.common.businessentities.TagsUserMap)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 RowMapper (org.springframework.jdbc.core.RowMapper)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1