public TypeManager(ToscaEnvironment toscaEnvironment) { this.toscaEnvironment = toscaEnvironment; INamedEntity[] basicTypes = { TypeString.instance(), TypeBoolean.instance(), TypeFloat.instance(), TypeInteger.instance(), TypeRange.instance(), TypeScalarUnit.instance() }; for (INamedEntity basicType : basicTypes) { this.basicTypes.put(basicType.name(), (IType) basicType); } this.nodeTypes.put("tosca.nodes.Root", NodeRoot.instance()); NamedStruct emptyStruct = new NamedStruct("emptyStruct", new TypeStruct(null, "", Collections.emptyMap())); emptyStruct.hidden = true; this.structTypes.put("emptyStruct", emptyStruct); }
INamedEntity importNodeTemplate(INamedEntity entity) { INamedEntity res; importNodeType((INamedEntity) ((INodeTemplate) entity).baseType()); for (Map.Entry<String, IProperty> property : ((INodeTemplate) entity).declaredProperties().entrySet()) { if (property.getValue().type() instanceof INamedEntity) toscaEnvironment.importWithSupertypes((INamedEntity) property.getValue().type()); else if (property.getValue().type() instanceof ICoercedType) toscaEnvironment.importWithSupertypes( (INamedEntity) ((ICoercedType) property.getValue().type()).baseType()); else if (property.getValue().type() instanceof ITypeStruct) importStructType((INamedEntity) ((ITypeStruct) property.getValue().type()).baseType()); } res = toscaEnvironment.registerNodeTemplate(entity.name(), (INodeTemplate) entity); return res; }