Search in sources :

Example 61 with Profile

use of io.fabric8.api.Profile in project fabric8 by jboss-fuse.

the class FabricManager method deleteConfigurationFile.

@Override
public void deleteConfigurationFile(String versionId, String profileId, String fileName) {
    Profile profile = profileService.getRequiredProfile(versionId, profileId);
    ProfileBuilder builder = ProfileBuilder.Factory.createFrom(profile);
    builder.deleteFileConfiguration(fileName);
    profileService.updateProfile(builder.getProfile());
}
Also used : ProfileBuilder(io.fabric8.api.ProfileBuilder) Profile(io.fabric8.api.Profile)

Example 62 with Profile

use of io.fabric8.api.Profile in project fabric8 by jboss-fuse.

the class FabricManager method containers.

@Override
public List<Map<String, Object>> containers(List<String> fields, List<String> profileFields) {
    List<Map<String, Object>> answer = new ArrayList<Map<String, Object>>();
    for (Container c : fabricService.getContainers()) {
        Map<String, Object> map = BeanUtils.convertContainerToMap(fabricService, c, fields);
        List<Map<String, Object>> profiles = new ArrayList<Map<String, Object>>();
        for (Profile p : c.getProfiles()) {
            profiles.add(BeanUtils.convertProfileToMap(fabricService, p, profileFields));
        }
        map.put("profiles", profiles);
        answer.add(map);
    }
    return answer;
}
Also used : Container(io.fabric8.api.Container) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) Profile(io.fabric8.api.Profile)

Example 63 with Profile

use of io.fabric8.api.Profile in project fabric8 by jboss-fuse.

the class FabricManager method getConfigurationFileNames.

@Override
public List<String> getConfigurationFileNames(String versionId, String profileId) {
    Version version = profileService.getVersion(versionId);
    Profile profile = version.getProfile(profileId);
    if (profile != null) {
        ArrayList<String> fileNames = new ArrayList<>(profile.getConfigurationFileNames());
        return Collections.unmodifiableList(fileNames);
    } else {
        return Collections.emptyList();
    }
}
Also used : GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version) ArrayList(java.util.ArrayList) Profile(io.fabric8.api.Profile)

Example 64 with Profile

use of io.fabric8.api.Profile in project fabric8 by jboss-fuse.

the class FabricManager method createProfile.

@Override
public Map<String, Object> createProfile(String versionId, String profileId, List<String> parents) {
    ProfileBuilder builder = ProfileBuilder.Factory.create(versionId, profileId).addParents(parents);
    Profile profile = profileService.createProfile(builder.getProfile());
    return getProfile(versionId, profile.getId());
}
Also used : ProfileBuilder(io.fabric8.api.ProfileBuilder) Profile(io.fabric8.api.Profile)

Example 65 with Profile

use of io.fabric8.api.Profile in project fabric8 by jboss-fuse.

the class FabricManager method containersForProfile.

@Override
public List<Map<String, Object>> containersForProfile(String versionId, String profileId, List<String> fields, boolean checkParents) {
    Version version = profileService.getVersion(versionId);
    Profile profile = version != null ? version.getRequiredProfile(profileId) : null;
    Set<Map<String, Object>> answer = new LinkedHashSet<Map<String, Object>>();
    if (profile != null) {
        for (Container c : fabricService.getContainers()) {
            for (Profile p : c.getProfiles()) {
                if (p.equals(profile)) {
                    answer.add(BeanUtils.convertContainerToMap(fabricService, c, fields));
                } else if (checkParents) {
                    HashSet<Profile> profileIDs = new HashSet<>();
                    getAllParentProfiles(version, p, profileIDs);
                    for (Profile pprofile : profileIDs) {
                        if (pprofile.equals(profile)) {
                            answer.add(BeanUtils.convertContainerToMap(fabricService, c, fields));
                            break;
                        }
                    }
                }
            }
        }
    }
    return new ArrayList<>(answer);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Container(io.fabric8.api.Container) GitVersion(io.fabric8.api.commands.GitVersion) Version(io.fabric8.api.Version) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) Profile(io.fabric8.api.Profile) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

Profile (io.fabric8.api.Profile)125 Version (io.fabric8.api.Version)50 Container (io.fabric8.api.Container)49 ArrayList (java.util.ArrayList)37 ProfileBuilder (io.fabric8.api.ProfileBuilder)34 Test (org.junit.Test)32 FabricService (io.fabric8.api.FabricService)28 HashMap (java.util.HashMap)25 File (java.io.File)24 ProfileService (io.fabric8.api.ProfileService)23 Map (java.util.Map)22 IOException (java.io.IOException)19 ProfileRequirements (io.fabric8.api.ProfileRequirements)13 HashSet (java.util.HashSet)12 GitVersion (io.fabric8.api.commands.GitVersion)11 FabricRequirements (io.fabric8.api.FabricRequirements)10 LinkedList (java.util.LinkedList)9 TreeMap (java.util.TreeMap)9 LockHandle (io.fabric8.api.LockHandle)8 Parser (io.fabric8.maven.util.Parser)8