Example #1
0
 public static NodeType create(EntityType entityType, NodeSpec nodeSpec) {
   NodeType nodeType = new NodeType(entityType);
   nodeType.name = nodeSpec.getName();
   nodeType.javaType = nodeSpec.getJavaType();
   System.out.println(
       nodeSpec.getEntity().getClassName()
           + "."
           + nodeSpec.getName()
           + "  "
           + nodeSpec.getRelationSpec());
   if (nodeSpec.getRelationSpec() != null) {
     RelationSpec spec = nodeSpec.getRelationSpec();
     NodeSpec backReference = spec.getBackReference();
     NodeSpec sortNode = spec.getSortNode();
     NodeSpec onwardJoin = spec.getOwnwardJoin();
     nodeType.relation =
         new Relation(
             spec.getEntitySpec().getClassName(),
             spec.getType(),
             backReference != null ? backReference.getName() : null,
             sortNode != null ? sortNode.getName() : null,
             onwardJoin != null ? onwardJoin.getName() : null);
   }
   nodeType.columnName = nodeSpec.getColumnName();
   nodeType.jdbcType = nodeSpec.getJdbcType();
   nodeType.mandatory = nodeSpec.getNullable() == Nullable.NOT_NULL;
   nodeType.optimisticLock = nodeSpec.isOptimisticLock();
   nodeType.enumSpec = nodeSpec.getEnumSpec();
   if (nodeType.getEnumSpec() != null) {
     try {
       nodeType.enumType =
           NodeType.class.getClassLoader().loadClass(nodeSpec.getEnumSpec().getClassName());
     } catch (ClassNotFoundException e) {
       LOG.info("Enum class " + nodeSpec.getEnumSpec().getClassName() + " is not available.");
     }
   }
   if (nodeSpec.getFixedValue() != null) {
     if (nodeType.getEnumSpec() != null) {
       nodeType.fixedValue = convertToEnum(nodeType, nodeSpec.getFixedValue());
     } else {
       nodeType.fixedValue = nodeSpec.getFixedValue();
     }
   }
   nodeType.typeConverterFqn = nodeSpec.getTypeConverter();
   return nodeType;
 }