public INamedEntity registerNodeTemplate(String name, INodeTemplate nodeType) { final NodeTemplate unnamed; if (nodeTypes.containsKey(name)) return null; if (nodeType instanceof NodeTemplate) unnamed = (NodeTemplate) nodeType; else { INodeType parentType = nodeType.baseType(); if (parentType != null && !(parentType instanceof NodeTemplate)) parentType = nodeTypes.get(((INamedEntity) parentType).name()); unnamed = new NodeTemplate( (NodeType) parentType, nodeType.description(), nodeType.declaredProperties(), nodeType.declaredAttributes()); } NamedNodeTemplate t = new NamedNodeTemplate(name, unnamed); nodeTemplates.put(name, t); return t; }
public INamedEntity registerType(String name, IType type) { if (type instanceof ITypeStruct) { ITypeStruct struct = (ITypeStruct) type; final TypeStruct unnamed; if (nodeTypes.containsKey(name)) return null; if (struct instanceof TypeStruct) unnamed = (TypeStruct) struct; else { ITypeStruct parentType = struct.baseType(); if (parentType != null && !(parentType instanceof TypeStruct)) parentType = structTypes.get(((INamedEntity) parentType).name()); unnamed = new TypeStruct( (TypeStruct) parentType, struct.description(), struct.declaredProperties()); } NamedStruct t = new NamedStruct(name, unnamed); structTypes.put(name, t); return t; } else if (type instanceof ICoercedType) { coercedTypes.put(name, new NamedCoercedType(name, (ICoercedType) type)); } return null; }
public void renameEntity(String entityName, String newEntityName) { NamedNodeTemplate template = nodeTemplates.remove(entityName); if (template != null) { template.rename(newEntityName); nodeTemplates.put(newEntityName, template); } NamedNodeType nodeType = nodeTypes.remove(entityName); if (nodeType != null) { nodeType.rename(newEntityName); nodeTypes.put(newEntityName, nodeType); } NamedStruct struct = structTypes.remove(entityName); if (struct != null) { struct.rename(newEntityName); structTypes.put(newEntityName, struct); } }
public Iterable<ITypeStruct> getTypesDerivingFrom(ITypeStruct rootType) { return Iterables.transform( Iterables.filter(structTypes.values(), t -> t.derivesFrom(rootType) && !t.hidden), t -> (ITypeStruct) t); }
public Iterable<INodeType> getNodeTypesDerivingFrom(INodeType rootType) { return Iterables.transform( Iterables.filter(nodeTypes.values(), t -> !t.hidden && t.derivesFrom(rootType)), t -> (INodeType) t); }
public IType getType(String typename) { IType ret = basicTypes.get(typename); if (ret == null) ret = structTypes.get(typename); return ret; }
public INodeType getNodeType(String typename) { return nodeTypes.get(typename); }
public INodeTemplate getNodeTemplate(String entityName) { return nodeTemplates.get(entityName); }
public Iterable<INodeTemplate> getNodeTemplatesOfType(INodeType rootType) { return Iterables.transform( Iterables.filter(nodeTemplates.values(), t -> t.derivesFrom(rootType)), t -> (INodeTemplate) t); }