Search in sources :

Example 6 with TagsVmMap

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

the class TagDaoImpl method getTagVmMapByVmIdAndDefaultTag.

@Override
public List<TagsVmMap> getTagVmMapByVmIdAndDefaultTag(Guid vmid) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("vm_id", vmid);
    RowMapper<TagsVmMap> mapper = (rs, rowNum) -> {
        TagsVmMap entity = new TagsVmMap();
        entity.setTagId(getGuidDefaultEmpty(rs, "tag_id"));
        entity.setVmId(getGuidDefaultEmpty(rs, "vm_id"));
        entity.setDefaultDisplayType((Integer) rs.getObject("DefaultDisplayType"));
        return entity;
    };
    return getCallsHandler().executeReadList("GetnVmTagsByVmIdAndDefaultTag", 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) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap)

Example 7 with TagsVmMap

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

the class TagDaoTest method updateVmTag.

@Test
public void updateVmTag() {
    existingVmTag.setDefaultDisplayType(existingVmTag.getDefaultDisplayType() + 1);
    dao.updateDefaultDisplayForVmTag(existingVmTag);
    TagsVmMap result = dao.getTagVmByTagIdAndByVmId(existingVmTag.getTagId(), existingVmTag.getVmId());
    assertNotNull(result);
    assertEqualsTagsVmMap(existingVmTag, result);
}
Also used : TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap) Test(org.junit.Test)

Example 8 with TagsVmMap

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

the class TagDaoTest method testAttachVmToTag.

@Test
public void testAttachVmToTag() {
    dao.attachVmToTag(newVmTag);
    TagsVmMap result = dao.getTagVmByTagIdAndByVmId(newVmTag.getTagId(), newVmTag.getVmId());
    assertNotNull(result);
    assertEqualsTagsVmMap(newVmTag, result);
}
Also used : TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap) Test(org.junit.Test)

Example 9 with TagsVmMap

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

the class UpdateTagsVmMapDefaultDisplayTypeCommand method validate.

@Override
protected boolean validate() {
    TagsVmMap tagsVmMap;
    tagsVmMap = tagDao.getTagVmByTagIdAndByVmId(getParameters().getTagsVmMap().getTagId(), getParameters().getTagsVmMap().getVmId());
    if (tagsVmMap == null) {
        addValidationMessage(EngineMessage.TAGS_SPECIFY_TAG_IS_NOT_EXISTS);
        return false;
    }
    return true;
}
Also used : TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap)

Example 10 with TagsVmMap

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

the class AttachVmsToTagCommand method executeCommand.

@Override
protected void executeCommand() {
    if (getTagId() != null) {
        for (Guid vmGuid : getVmsList()) {
            VM vm = vmDao.get(vmGuid);
            if (tagDao.getTagVmByTagIdAndByVmId(getTagId(), vmGuid) == null) {
                if (vm != null) {
                    appendCustomCommaSeparatedValue("VmsNames", vm.getName());
                }
                TagsVmMap map = new TagsVmMap(getTagId(), vmGuid);
                tagDao.attachVmToTag(map);
                noActionDone = false;
            } else {
                if (vm != null) {
                    appendCustomCommaSeparatedValue("VmsNamesExists", vm.getName());
                }
            }
        }
    }
    setSucceeded(true);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) TagsVmMap(org.ovirt.engine.core.common.businessentities.TagsVmMap) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

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