use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirectorTest method testGetTagIdAndChildrenIdsNotExists.
@Test
public void testGetTagIdAndChildrenIdsNotExists() {
Tags tag = createTag("tag1", "desc1");
String idsStr = tagsDirector.getTagIdAndChildrenIds(tag.getTagId());
assertEquals(StringUtils.EMPTY, idsStr);
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class UpdateTagCommand method validate.
@Override
protected boolean validate() {
// we fetch by new name to see if it is in use
Tags tag = tagDao.getByName(getParameters().getTag().getTagName());
if (tag != null && !tag.getTagId().equals(getParameters().getTag().getTagId())) {
addValidationMessage(EngineMessage.TAGS_SPECIFY_TAG_IS_IN_USE);
return false;
}
// we fetch by id to see if the tag is realy read-only
tag = tagDao.get(getParameters().getTag().getTagId());
if (tag.getIsReadonly() != null && tag.getIsReadonly()) {
addValidationMessage(EngineMessage.TAGS_CANNOT_EDIT_READONLY_TAG);
return false;
}
return true;
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirector method getTagIdAndChildrenIds.
/**
* This function will return the tag's ID and its children IDs. Its used to determine if a tag is assigned to an
* entity. Tag is determined as assigned to an entity if the entity is assigned to the tag or to one of its
* children.
*
* @param tagName
* the name of the 'root' tag.
* @return a comma separated list of IDs.
*/
public String getTagIdAndChildrenIds(String tagName) {
Tags tag = getTagByTagName(tagName);
StringBuilder sb = tag.getTagIdAndChildrenIds();
return sb.toString();
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirector method addTagToHash.
private void addTagToHash(Tags tag) {
tagsMapByID.put(tag.getTagId(), tag);
tagsMapByName.put(tag.getTagName(), tag);
if (tag.getParentId() != null) {
// If the tag has a parent, the parent should have in its children the added tag instead
// of the old version of the tag , if exists
Tags parentTag = tagsMapByID.get(tag.getParentId());
if (parentTag == null) {
log.error("Could not obtain tag for guid '{}'", tag.getParentId());
return;
}
List<Tags> parentChildren = parentTag.getChildren();
replaceTagInChildren(tag, parentChildren);
// replace the parent tag after the modification
addTagToHash(parentTag);
}
}
use of org.ovirt.engine.core.common.businessentities.Tags in project ovirt-engine by oVirt.
the class TagsDirector method addTag.
public void addTag(Tags tag) {
if (tagsMapByID.containsKey(tag.getParentId())) {
Tags parent = tagsMapByID.get(tag.getParentId());
parent.getChildren().add(tag);
addTagToHash(tag);
addTagToHash(parent);
} else {
log.error("Trying to add tag '{}', parent doesn't exist in Data Structure - '{}'", tag.getTagName(), tag.getParentId());
}
}
Aggregations