Beispiel #1
0
 private Set<String> initializeNamespaces() {
   Set<String> allNamespaces = new HashSet<String>();
   for (String namespace : _typeDataByNamespace.get().keySet()) {
     splitStringInto(allNamespaces, namespace);
   }
   for (SQLFileInfo sqlFileInfo : _sqlFilesByName.get().values()) {
     splitStringInto(allNamespaces, GosuClassUtil.getPackage(sqlFileInfo.getTypeName()));
   }
   return allNamespaces;
 }
Beispiel #2
0
  private Set<String> initializeTypeNames() {
    Set<String> typeNames = new HashSet<String>();

    for (IDatabase database : _typeDataByNamespace.get().values()) {
      typeNames.add(database.getNamespace() + "." + TransactionType.TYPE_NAME);
      typeNames.add(database.getNamespace() + "." + DatabaseAccessType.TYPE_NAME);
      for (IDBTable table : database.getAllTables()) {
        if (!table.getName().contains("join_")) {
          // TODO - AHK - Should there be a utility method for converting from table to entity name?
          typeNames.add(database.getNamespace() + "." + table.getName());
        }
      }
    }
    for (SQLFileInfo sqlFileInfo : _sqlFilesByName.get().values()) {
      typeNames.add(sqlFileInfo.getTypeName());
    }
    return typeNames;
  }
Beispiel #3
0
  @Override
  public IType getType(String fullyQualifiedName) {
    int lastDot = fullyQualifiedName.lastIndexOf('.');
    if (lastDot == -1) {
      return null;
    }
    // TODO - AHK - What do we do if there's a table named "Transaction"?
    // TODO - AHK - Is it really our job to do any caching at all?
    String namespace = fullyQualifiedName.substring(0, lastDot);
    String relativeName = fullyQualifiedName.substring(lastDot + 1);
    DatabaseImpl databaseImpl = _typeDataByNamespace.get().get(namespace);
    if (databaseImpl == null) {
      SQLFileInfo data = _sqlFilesByName.get().get(fullyQualifiedName);
      if (data != null) {
        SQLType sqlType = new SQLType(data, this);
        addTypeForFile(data.getSqlFile(), sqlType);
        return sqlType.getTypeReference();
      } else {
        return null;
      }
    }

    IType rVal = null;
    if (TransactionType.TYPE_NAME.equals(relativeName)) {
      // TODO - AHK - Turn that into a type reference
      rVal = new TransactionType(databaseImpl, this).getTypeReference();
    } else if (DatabaseAccessType.TYPE_NAME.equals(relativeName)) {
      rVal = new DatabaseAccessType(databaseImpl, this).getTypeReference();
    } else {
      IDBTable dbTable = databaseImpl.getTable(relativeName);
      if (dbTable != null) {
        rVal = new DBType(this, dbTable).getTypeReference();
      }
    }

    if (rVal != null) {
      addTypeForFile(databaseImpl.getDdlFile(), rVal);
    }
    return rVal;
  }