use of org.bimserver.models.store.DatabaseInformationItem 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;
}
Aggregations