Search in sources :

Example 1 with DatabaseInformation

use of org.bimserver.models.store.DatabaseInformation 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)

Example 2 with DatabaseInformation

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

the class AdminServiceImpl method getDatabaseInformation.

@Override
public SDatabaseInformation getDatabaseInformation() throws ServerException, UserException {
    requireAdminAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<DatabaseInformation> action = new GetDatabaseInformationAction(session, getInternalAccessMethod());
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(action));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseInformation(org.bimserver.models.store.DatabaseInformation) SDatabaseInformation(org.bimserver.interfaces.objects.SDatabaseInformation) DatabaseSession(org.bimserver.database.DatabaseSession) GetDatabaseInformationAction(org.bimserver.database.actions.GetDatabaseInformationAction) UserException(org.bimserver.shared.exceptions.UserException) BimBotsException(org.bimserver.bimbots.BimBotsException) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Aggregations

DatabaseInformation (org.bimserver.models.store.DatabaseInformation)2 IOException (java.io.IOException)1 Scanner (java.util.Scanner)1 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 BimBotsException (org.bimserver.bimbots.BimBotsException)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 GetDatabaseInformationAction (org.bimserver.database.actions.GetDatabaseInformationAction)1 SDatabaseInformation (org.bimserver.interfaces.objects.SDatabaseInformation)1 Checkout (org.bimserver.models.store.Checkout)1 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)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 ServerException (org.bimserver.shared.exceptions.ServerException)1 UserException (org.bimserver.shared.exceptions.UserException)1