Search in sources :

Example 1 with DatabaseInformationCategory

use of org.bimserver.models.store.DatabaseInformationCategory in project BIMserver by opensourceBIM.

the class DatabaseSession method getDatabaseInformation.

public DatabaseInformation getDatabaseInformation() throws BimserverDatabaseException {
    DatabaseInformation databaseInformation = StoreFactory.eINSTANCE.createDatabaseInformation();
    databaseInformation.setNumberOfProjects(getObjectCount(Project.class, OldQuery.getDefault()));
    databaseInformation.setNumberOfUsers(getObjectCount(User.class, OldQuery.getDefault()));
    databaseInformation.setNumberOfCheckouts(getObjectCount(Checkout.class, OldQuery.getDefault()));
    databaseInformation.setNumberOfRevisions(getObjectCount(ConcreteRevision.class, OldQuery.getDefault()));
    databaseInformation.setType(database.getKeyValueStore().getType());
    databaseInformation.setCreated(database.getCreated());
    databaseInformation.setDatabaseSizeInBytes(database.getKeyValueStore().getDatabaseSizeInBytes());
    databaseInformation.setSchemaVersion(database.getRegistry().readInt(Database.SCHEMA_VERSION, this));
    String stats = database.getKeyValueStore().getStats();
    Scanner scanner = new Scanner(stats);
    try {
        DatabaseInformationCategory category = StoreFactory.eINSTANCE.createDatabaseInformationCategory();
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            if (line.contains("=")) {
                DatabaseInformationItem item = StoreFactory.eINSTANCE.createDatabaseInformationItem();
                category.getItems().add(item);
                item.setKey(line.substring(0, line.indexOf("=")));
                item.setValue(line.substring(line.indexOf("=") + 1));
            } else {
                category = StoreFactory.eINSTANCE.createDatabaseInformationCategory();
                category.setTitle(line);
                databaseInformation.getCategories().add(category);
            }
        }
    } finally {
        scanner.close();
    }
    databaseInformation.setLocation(database.getKeyValueStore().getLocation());
    return databaseInformation;
}
Also used : DatabaseInformation(org.bimserver.models.store.DatabaseInformation) Project(org.bimserver.models.store.Project) Scanner(java.util.Scanner) User(org.bimserver.models.store.User) Checkout(org.bimserver.models.store.Checkout) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) DatabaseInformationCategory(org.bimserver.models.store.DatabaseInformationCategory) DatabaseInformationItem(org.bimserver.models.store.DatabaseInformationItem)

Aggregations

Scanner (java.util.Scanner)1 Checkout (org.bimserver.models.store.Checkout)1 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)1 DatabaseInformation (org.bimserver.models.store.DatabaseInformation)1 DatabaseInformationCategory (org.bimserver.models.store.DatabaseInformationCategory)1 DatabaseInformationItem (org.bimserver.models.store.DatabaseInformationItem)1 Project (org.bimserver.models.store.Project)1 User (org.bimserver.models.store.User)1