public static Collection<TagDefinitionModelDao> get(final boolean includeSystemTags) { final Collection<TagDefinitionModelDao> all = includeSystemTags ? new LinkedList<TagDefinitionModelDao>(SYSTEM_DEFINED_TAG_DEFINITIONS) : new LinkedList<TagDefinitionModelDao>(); for (final ControlTagType controlTag : ControlTagType.values()) { all.add(new TagDefinitionModelDao(controlTag)); } return all; }
public static boolean isControlTag(final String definitionName) { for (final ControlTagType controlTagName : ControlTagType.values()) { if (controlTagName.toString().equals(definitionName)) { return true; } } return false; }
public static boolean isControlTag(final UUID tagDefinitionId) { for (final ControlTagType controlTag : ControlTagType.values()) { if (controlTag.getId().equals(tagDefinitionId)) { return true; } } return false; } }
private void validateApplicableObjectTypes(final UUID tagDefinitionId, final ObjectType objectType) throws TagApiException { final ControlTagType controlTagType = Iterables.tryFind(ImmutableList.<ControlTagType>copyOf(ControlTagType.values()), new Predicate<ControlTagType>() { @Override public boolean apply(final ControlTagType input) { return input.getId().equals(tagDefinitionId); } }).orNull(); if (controlTagType != null && !controlTagType.getApplicableObjectTypes().contains(objectType)) { // TODO Add missing ErrorCode.TAG_NOT_APPLICABLE // throw new TagApiException(ErrorCode.TAG_NOT_APPLICABLE); throw new IllegalStateException(String.format("Invalid control tag '%s' for object type '%s'", controlTagType.name(), objectType)); } }
private static List<ObjectType> getApplicableObjectTypes(final UUID id, final Boolean isControlTag) { if (!isControlTag) { return ImmutableList.<ObjectType>copyOf(ObjectType.values()); } for (final ControlTagType cur : ControlTagType.values()) { if (cur.getId().equals(id)) { return cur.getApplicableObjectTypes(); } } throw new IllegalStateException(String.format("ControlTag id %s does not seem to exist", id)); }
public static TagDefinitionModelDao lookup(final String tagDefinitionName) { for (final ControlTagType t : ControlTagType.values()) { if (t.name().equals(tagDefinitionName)) { return new TagDefinitionModelDao(t); } } for (final TagDefinitionModelDao t : SYSTEM_DEFINED_TAG_DEFINITIONS) { if (t.getName().equals(tagDefinitionName)) { return t; } } return null; }
public static TagDefinitionModelDao lookup(final UUID tagDefinitionId) { for (final ControlTagType t : ControlTagType.values()) { if (t.getId().equals(tagDefinitionId)) { return new TagDefinitionModelDao(t); } } for (final TagDefinitionModelDao t : SYSTEM_DEFINED_TAG_DEFINITIONS) { if (t.getId().equals(tagDefinitionId)) { return t; } } return null; } }
@Test(groups = "slow") public void testGetTagDefinitions() { final List<TagDefinitionModelDao> definitionList = tagDefinitionDao.getTagDefinitions(false, internalCallContext); assertTrue(definitionList.size() >= ControlTagType.values().length); } }
@Test(groups = "fast") public void testDefaultTagDefinition() throws TagApiException, TagDefinitionApiException { final DefaultTagDefinition def1 = new DefaultTagDefinition(UUID.randomUUID(), "foo", "nothing", false); Assert.assertFalse(def1.getApplicableObjectTypes().isEmpty()); Assert.assertEquals(ImmutableList.<ObjectType>copyOf(ObjectType.values()), def1.getApplicableObjectTypes()); for (final ControlTagType cur : ControlTagType.values()) { final DefaultTagDefinition curDef = new DefaultTagDefinition(cur.getId(), cur.name(), cur.getDescription(), true); Assert.assertFalse(curDef.getApplicableObjectTypes().isEmpty()); Assert.assertEquals(curDef.getApplicableObjectTypes(), cur.getApplicableObjectTypes()); } try { new DefaultTagDefinition(UUID.randomUUID(), "bar", "nothing again", true); Assert.fail("Not a control tag type"); } catch (final IllegalStateException e) { } } }
public static boolean isControlTag(final String definitionName) { for (final ControlTagType controlTagName : ControlTagType.values()) { if (controlTagName.toString().equals(definitionName)) { return true; } } return false; }
public static boolean isControlTag(final UUID tagDefinitionId) { for (final ControlTagType controlTag : ControlTagType.values()) { if (controlTag.getId().equals(tagDefinitionId)) { return true; } } return false; } }
public static Collection<TagDefinitionModelDao> get(final boolean includeSystemTags) { final Collection<TagDefinitionModelDao> all = includeSystemTags ? new LinkedList<TagDefinitionModelDao>(SYSTEM_DEFINED_TAG_DEFINITIONS) : new LinkedList<TagDefinitionModelDao>(); for (final ControlTagType controlTag : ControlTagType.values()) { all.add(new TagDefinitionModelDao(controlTag)); } return all; }
public static ControlTagType getTypeFromId(final UUID targetId) { for (ControlTagType cur : values()) { if (cur.getId().equals(targetId)) { return cur; } } return null; }
public static ControlTagType getTypeFromId(final UUID targetId) { for (ControlTagType cur : values()) { if (cur.getId().equals(targetId)) { return cur; } } return null; }
private void validateApplicableObjectTypes(final UUID tagDefinitionId, final ObjectType objectType) throws TagApiException { final ControlTagType controlTagType = Iterables.tryFind(ImmutableList.<ControlTagType>copyOf(ControlTagType.values()), new Predicate<ControlTagType>() { @Override public boolean apply(final ControlTagType input) { return input.getId().equals(tagDefinitionId); } }).orNull(); if (controlTagType != null && !controlTagType.getApplicableObjectTypes().contains(objectType)) { // TODO Add missing ErrorCode.TAG_NOT_APPLICABLE // throw new TagApiException(ErrorCode.TAG_NOT_APPLICABLE); throw new IllegalStateException(String.format("Invalid control tag '%s' for object type '%s'", controlTagType.name(), objectType)); } }
private static List<ObjectType> getApplicableObjectTypes(final UUID id, final Boolean isControlTag) { if (!isControlTag) { return ImmutableList.<ObjectType>copyOf(ObjectType.values()); } for (final ControlTagType cur : ControlTagType.values()) { if (cur.getId().equals(id)) { return cur.getApplicableObjectTypes(); } } throw new IllegalStateException(String.format("ControlTag id %s does not seem to exist", id)); }
public static TagDefinitionModelDao lookup(final UUID tagDefinitionId) { for (final ControlTagType t : ControlTagType.values()) { if (t.getId().equals(tagDefinitionId)) { return new TagDefinitionModelDao(t); } } for (final TagDefinitionModelDao t : SYSTEM_DEFINED_TAG_DEFINITIONS) { if (t.getId().equals(tagDefinitionId)) { return t; } } return null; } }
public static TagDefinitionModelDao lookup(final String tagDefinitionName) { for (final ControlTagType t : ControlTagType.values()) { if (t.name().equals(tagDefinitionName)) { return new TagDefinitionModelDao(t); } } for (final TagDefinitionModelDao t : SYSTEM_DEFINED_TAG_DEFINITIONS) { if (t.getName().equals(tagDefinitionName)) { return t; } } return null; }
@Test(groups = "slow") public void testGetTagDefinitions() { final List<TagDefinitionModelDao> definitionList = tagDefinitionDao.getTagDefinitions(false, internalCallContext); assertTrue(definitionList.size() >= ControlTagType.values().length); } }
@Test(groups = "fast") public void testDefaultTagDefinition() throws TagApiException, TagDefinitionApiException { final DefaultTagDefinition def1 = new DefaultTagDefinition(UUID.randomUUID(), "foo", "nothing", false); Assert.assertFalse(def1.getApplicableObjectTypes().isEmpty()); Assert.assertEquals(ImmutableList.<ObjectType>copyOf(ObjectType.values()), def1.getApplicableObjectTypes()); for (final ControlTagType cur : ControlTagType.values()) { final DefaultTagDefinition curDef = new DefaultTagDefinition(cur.getId(), cur.name(), cur.getDescription(), true); Assert.assertFalse(curDef.getApplicableObjectTypes().isEmpty()); Assert.assertEquals(curDef.getApplicableObjectTypes(), cur.getApplicableObjectTypes()); } try { new DefaultTagDefinition(UUID.randomUUID(), "bar", "nothing again", true); Assert.fail("Not a control tag type"); } catch (final IllegalStateException e) { } } }