Search in sources :

Example 1 with TagsUserGroupMap

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

the class TagDaoTest method testGetTagUserGroupByGroupIdAndTagId.

@Test
public void testGetTagUserGroupByGroupIdAndTagId() {
    TagsUserGroupMap result = dao.getTagUserGroupByGroupIdAndByTagId(existingUserGroupTag.getTagId(), existingUserGroupTag.getGroupId());
    assertNotNull(result);
    assertEqualsTagUserGroupMap(existingUserGroupTag, result);
}
Also used : TagsUserGroupMap(org.ovirt.engine.core.common.businessentities.TagsUserGroupMap) Test(org.junit.Test)

Example 2 with TagsUserGroupMap

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

the class TagDaoImpl method getTagUserGroupByGroupIdAndByTagId.

@Override
public TagsUserGroupMap getTagUserGroupByGroupIdAndByTagId(Guid tag, Guid group) {
    MapSqlParameterSource parameterSource = getCustomMapSqlParameterSource().addValue("group_id", group).addValue("tag_id", tag);
    RowMapper<TagsUserGroupMap> mapper = (rs, rowNum) -> {
        TagsUserGroupMap entity = new TagsUserGroupMap();
        entity.setGroupId(getGuidDefaultEmpty(rs, "group_id"));
        entity.setTagId(getGuidDefaultEmpty(rs, "tag_id"));
        return entity;
    };
    return getCallsHandler().executeRead("GetTagUserGroupByGroupIdAndByTagId", 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) TagsUserGroupMap(org.ovirt.engine.core.common.businessentities.TagsUserGroupMap)

Example 3 with TagsUserGroupMap

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

the class TagDaoTest method testDetachUserGroupFromTag.

@Test
public void testDetachUserGroupFromTag() {
    dao.detachUserGroupFromTag(existingUserGroupTag.getTagId(), existingUserGroupTag.getGroupId());
    TagsUserGroupMap result = dao.getTagUserGroupByGroupIdAndByTagId(existingUserGroupTag.getTagId(), existingUserGroupTag.getGroupId());
    assertNull(result);
}
Also used : TagsUserGroupMap(org.ovirt.engine.core.common.businessentities.TagsUserGroupMap) Test(org.junit.Test)

Example 4 with TagsUserGroupMap

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

the class AttachUserGroupToTagCommand method executeCommand.

@Override
protected void executeCommand() {
    if (getTagId() != null) {
        for (Guid groupGuid : getGroupList()) {
            DbGroup group = dbGroupDao.get(groupGuid);
            if (tagDao.getTagUserGroupByGroupIdAndByTagId(getTagId(), groupGuid) == null) {
                TagsUserGroupMap map = new TagsUserGroupMap(groupGuid, getTagId());
                tagDao.attachUserGroupToTag(map);
                noActionDone = false;
                if (group != null) {
                    appendCustomCommaSeparatedValue("AttachGroupsNames", group.getName());
                }
            } else {
                if (group != null) {
                    appendCustomCommaSeparatedValue("AttachGroupsNamesExists", group.getName());
                }
            }
        }
        setSucceeded(true);
    }
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) TagsUserGroupMap(org.ovirt.engine.core.common.businessentities.TagsUserGroupMap) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

TagsUserGroupMap (org.ovirt.engine.core.common.businessentities.TagsUserGroupMap)4 Test (org.junit.Test)2 Guid (org.ovirt.engine.core.compat.Guid)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 Tags (org.ovirt.engine.core.common.businessentities.Tags)1 TagsTemplateMap (org.ovirt.engine.core.common.businessentities.TagsTemplateMap)1 TagsType (org.ovirt.engine.core.common.businessentities.TagsType)1 TagsUserMap (org.ovirt.engine.core.common.businessentities.TagsUserMap)1 TagsVdsMap (org.ovirt.engine.core.common.businessentities.TagsVdsMap)1 TagsVmMap (org.ovirt.engine.core.common.businessentities.TagsVmMap)1 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)1 RowMapper (org.springframework.jdbc.core.RowMapper)1 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)1