PropertyHelper.getKeyPropertyIds(Resource.Type.Blueprint),
null);
}
private BlueprintEntity createEntity(Map<String, Object> properties) {
BlueprintEntity entity = new BlueprintEntity();
entity.setBlueprintName((String) properties.get(BlueprintResourceProvider.BLUEPRINT_NAME_PROPERTY_ID));
entity.setStackName((String) properties.get(BlueprintResourceProvider.STACK_NAME_PROPERTY_ID));
entity.setStackVersion((String) properties.get(BlueprintResourceProvider.STACK_VERSION_PROPERTY_ID));
Set<Map<String, Object>> hostGroupProperties = (Set<Map<String, Object>>) properties.get(
BlueprintResourceProvider.HOST_GROUP_PROPERTY_ID);
Collection<HostGroupEntity> hostGroups = new ArrayList<HostGroupEntity>();
for (Map<String, Object> groupProperties : hostGroupProperties) {
HostGroupEntity hostGroup = new HostGroupEntity();
hostGroups.add(hostGroup);
hostGroup.setName((String) groupProperties.get(BlueprintResourceProvider.HOST_GROUP_NAME_PROPERTY_ID));
hostGroup.setCardinality((String) groupProperties.get(BlueprintResourceProvider.HOST_GROUP_CARDINALITY_PROPERTY_ID));
hostGroup.setConfigurations(new ArrayList<HostGroupConfigEntity>());
Set<Map<String, String>> setComponentProperties = (Set<Map<String, String>>) groupProperties.get(
BlueprintResourceProvider.COMPONENT_PROPERTY_ID);
Collection<HostGroupComponentEntity> components = new ArrayList<HostGroupComponentEntity>();
for (Map<String, String> compProperties : setComponentProperties) {
HostGroupComponentEntity component = new HostGroupComponentEntity();
components.add(component);
component.setName(compProperties.get(BlueprintResourceProvider.COMPONENT_NAME_PROPERTY_ID));
}
hostGroup.setComponents(components);
}
entity.setHostGroups(hostGroups);
Collection<Map<String, String>> configProperties = (Collection<Map<String, String>>) properties.get(
BlueprintResourceProvider.CONFIGURATION_PROPERTY_ID);
Map<String, String> configData = new HashMap<String, String>();
Collection<BlueprintConfigEntity> configs = new ArrayList<BlueprintConfigEntity>();
if (configProperties != null) {
for (Map<String, String> config : configProperties) {
BlueprintConfigEntity configEntity = new BlueprintConfigEntity();
for (Map.Entry<String, String> entry : config.entrySet()) {
String absolutePropName = entry.getKey();
int idx = absolutePropName.indexOf('/');
if (configEntity.getType() == null) {
configEntity.setType(absolutePropName.substring(0, idx));
}
configData.put(absolutePropName.substring(idx + 1), entry.getValue());
}
configEntity.setConfigData(gson.toJson(configData));
configs.add(configEntity);
}
}
entity.setConfigurations(configs);
return entity;
}