Esempio n. 1
0
 private Map<String, SQLFileInfo> initializeSQLFiles() {
   HashMap<String, SQLFileInfo> results = new HashMap<String, SQLFileInfo>();
   for (Pair<String, IFile> pair : _module.getFileRepository().findAllFilesByExtension(".sql")) {
     String fileName = pair.getFirst();
     IFile sqlFil = pair.getSecond();
     for (DatabaseImpl db : _typeDataByNamespace.get().values()) {
       if (sqlFil.isDescendantOf(db.getDBData().getDdlFile().getParent())) {
         String queryName =
             fileName.substring(0, fileName.length() - ".sql".length()).replace("/", ".");
         results.put(queryName, new SQLFileInfo(queryName, db, sqlFil));
         break;
       }
     }
   }
   return results;
 }
Esempio n. 2
0
 @Override
 public List<IType> getTypesForFile(IFile iFile) {
   List<IType> typesForFile = new ArrayList<IType>();
   if (iFile.getExtension().equals("ddl")) {
     Collection<DatabaseImpl> values = _typeDataByNamespace.get().values();
     for (DatabaseImpl value : values) {
       if (value.getDdlFile().equals(iFile)) {
         Collection<DBTableImpl> allTables = value.getAllTables();
         for (DBTableImpl table : allTables) {
           String tableTypeName = value.getNamespace() + "." + table.getName();
           IType type = TypeSystem.getByFullNameIfValid(tableTypeName);
           if (type != null) {
             typesForFile.add(type);
           }
         }
       }
     }
   }
   return typesForFile;
 }
Esempio n. 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;
  }