Search in sources :

Example 1 with Tag

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());
}
Also used : Tag(alien4cloud.model.common.Tag) Test(org.junit.Test)

Example 2 with Tag

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;
}
Also used : Tag(alien4cloud.model.common.Tag) Application(alien4cloud.model.application.Application) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment)

Example 3 with Tag

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());
            }
        }
    }
}
Also used : ImageData(alien4cloud.images.ImageData) Tag(alien4cloud.model.common.Tag) Map(java.util.Map)

Example 4 with Tag

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);
}
Also used : Tag(alien4cloud.model.common.Tag) Application(alien4cloud.model.application.Application) Location(alien4cloud.model.orchestrators.locations.Location) Before(org.junit.Before)

Example 5 with Tag

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()));
    }
}
Also used : AbstractToscaType(org.alien4cloud.tosca.model.types.AbstractToscaType) Tag(alien4cloud.model.common.Tag)

Aggregations

Tag (alien4cloud.model.common.Tag)24 NodeType (org.alien4cloud.tosca.model.types.NodeType)6 Application (alien4cloud.model.application.Application)4 Given (cucumber.api.java.en.Given)3 Test (org.junit.Test)3 When (cucumber.api.java.en.When)2 Map (java.util.Map)2 AbstractToscaType (org.alien4cloud.tosca.model.types.AbstractToscaType)2 MappingNode (org.yaml.snakeyaml.nodes.MappingNode)2 NodeTuple (org.yaml.snakeyaml.nodes.NodeTuple)2 GetMultipleDataResult (alien4cloud.dao.model.GetMultipleDataResult)1 CyclicReferenceException (alien4cloud.exception.CyclicReferenceException)1 ImageData (alien4cloud.images.ImageData)1 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)1 Location (alien4cloud.model.orchestrators.locations.Location)1 TopologyContext (alien4cloud.paas.wf.TopologyContext)1 ArchiveRoot (alien4cloud.tosca.model.ArchiveRoot)1 Then (cucumber.api.java.en.Then)1 Method (java.lang.reflect.Method)1 LinkedHashSet (java.util.LinkedHashSet)1