use of alien4cloud.model.common.Tag in project alien4cloud by alien4cloud.
the class IndexedModelTest method mergeInheritableIndexWithTags.
@Test
public void mergeInheritableIndexWithTags() {
IndexedModelUtils.mergeInheritableIndex(parent, sonWith3Tags);
// son should have 5 tags : 3 from himself 2 from his parent
assertEquals(sonWith3Tags.getTags().size(), 5);
// son should'nt have parent icon
;
for (Tag tag : sonWith3Tags.getTags()) {
if (tag.getName().equals("alienicon")) {
assertNotEquals(tag.getValue(), "/usr/local/root-icon.png");
assertEquals(tag.getValue(), "/usr/child-icon.png");
}
}
// son has all parent's tags
assertTrue(sonWith3Tags.getTags().containsAll(parent.getTags()));
// Parent witht 3 tags merged with son without tags => son with 3 tags
IndexedModelUtils.mergeInheritableIndex(parent, sonWithoutTags);
assertEquals(sonWithoutTags.getTags().size(), parent.getTags().size());
assertEquals(sonWithoutTags.getTags(), parent.getTags());
}
use of alien4cloud.model.common.Tag in project alien4cloud by alien4cloud.
the class AlienContextVariables method getProperty.
@Override
public Object getProperty(String name) {
if (!name.startsWith("a4c.")) {
return null;
}
switch(name) {
case "a4c.application":
return application;
case "a4c.application.id":
return ifNotNull(application, Application::getId);
case "a4c.application.name":
return ifNotNull(application, Application::getName);
case "a4c.environment.type":
return ifNotNull(applicationEnvironment, ApplicationEnvironment::getEnvironmentType);
case "a4c.environment.name":
return ifNotNull(applicationEnvironment, ApplicationEnvironment::getName);
}
// lookup for a tag
if (name.startsWith("a4c.application.tags.")) {
if (application != null && application.getTags() != null) {
String tagName = StringUtils.removeStart(name, "a4c.application.tags.");
for (Tag tag : application.getTags()) {
if (tag.getName().equals(tagName)) {
return tag.getValue();
}
}
}
}
// lookup for meta properties
String metaName = StringUtils.removeStart(name, "a4c.");
String metaValue = findMetaProperties(metaName, application);
if (metaValue != null) {
return metaValue;
}
metaValue = findMetaProperties(metaName, location);
if (metaValue != null) {
return metaValue;
}
return null;
}
use of alien4cloud.model.common.Tag in project alien4cloud by alien4cloud.
the class ArchiveImageLoaderTest method checkImages.
private void checkImages(Map<String, ? extends AbstractInheritableToscaType> elements) {
boolean elementHasTags = false;
String currentUUID = null;
ImageData image = null;
Tag iconTag = new Tag("icon", "");
for (Map.Entry<String, ? extends AbstractInheritableToscaType> toscaInheritableElement : elements.entrySet()) {
elementHasTags = toscaInheritableElement.getValue().getTags() != null;
if (elementHasTags) {
int indexOfIcon = toscaInheritableElement.getValue().getTags().indexOf(iconTag);
if (indexOfIcon >= 0) {
currentUUID = toscaInheritableElement.getValue().getTags().get(indexOfIcon).getValue();
image = imageGenericIdDAO.findById(ImageData.class, currentUUID);
// get registered images in ES by the UUID
assertEquals(currentUUID, image.getId());
}
}
}
}
use of alien4cloud.model.common.Tag in project alien4cloud by alien4cloud.
the class AlienContextVariablesTest method setUp.
@Before
public void setUp() throws Exception {
alienContextVariables = new AlienContextVariables();
Application app = new Application();
app.setTags(Arrays.asList(new Tag("tagName", "tagValue"), new Tag("yolo", "oloy")));
app.setMetaProperties(ImmutableMap.of("meta1", "meta1 value", "meta2", "meta2 value"));
alienContextVariables.setApplication(app);
Location location = new Location();
location.setMetaProperties(ImmutableMap.of("loc_meta1", "meta1 value", "loc_meta2", "meta2 value"));
alienContextVariables.setLocation(location);
}
use of alien4cloud.model.common.Tag in project alien4cloud by alien4cloud.
the class PluginArchiveIndexer method injectWorkSpace.
private void injectWorkSpace(Collection<? extends AbstractToscaType> elements, Orchestrator orchestrator, Location location) {
for (AbstractToscaType element : elements) {
if (element.getTags() == null) {
element.setTags(new ArrayList<Tag>());
}
element.getTags().add(new Tag("alien-workspace-id", orchestrator.getId() + ":" + location.getId()));
element.getTags().add(new Tag("alien-workspace-name", orchestrator.getName() + " - " + location.getName()));
}
}
Aggregations