use of org.bimserver.models.ifc2x3tc1.IfcWall in project BIMserver by opensourceBIM.
the class CommandLine method run.
@Override
public void run() {
reader = new BufferedReader(new InputStreamReader(System.in));
running = true;
try {
while (running) {
try {
String line = reader.readLine();
if (line == null) {
Thread.sleep(50);
continue;
}
if (line.equalsIgnoreCase("exit")) {
bimServer.stop();
return;
} else if (line.startsWith("dumpmodel")) {
try {
long roid = Long.parseLong(line.substring(9).trim());
DatabaseSession databaseSession = bimServer.getDatabase().createSession();
try {
DownloadDatabaseAction downloadDatabaseAction = new DownloadDatabaseAction(bimServer, databaseSession, AccessMethod.INTERNAL, roid, -1, -1, new SystemAuthorization(1, TimeUnit.HOURS), null);
IfcModelInterface model = downloadDatabaseAction.execute();
LOGGER.info("Model size: " + model.size());
List<IfcWall> walls = model.getAll(IfcWall.class);
List<IfcProject> projects = model.getAll(IfcProject.class);
List<IfcSlab> slabs = model.getAll(IfcSlab.class);
List<IfcWindow> windows = model.getAll(IfcWindow.class);
LOGGER.info("Walls: " + walls.size());
LOGGER.info("Windows: " + windows.size());
LOGGER.info("Projects: " + projects.size());
LOGGER.info("Slabs: " + slabs.size());
} catch (UserException e) {
LOGGER.error("", e);
} catch (BimserverLockConflictException e) {
LOGGER.error("", e);
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} finally {
databaseSession.close();
}
} catch (Exception e) {
LOGGER.error("", e);
}
} else if (line.equalsIgnoreCase("dump")) {
LOGGER.info("Dumping all thread's track traces...");
LOGGER.info("");
Map<Thread, StackTraceElement[]> allStackTraces = Thread.getAllStackTraces();
for (Thread t : allStackTraces.keySet()) {
LOGGER.info(t.getName());
StackTraceElement[] stackTraceElements = allStackTraces.get(t);
for (StackTraceElement stackTraceElement : stackTraceElements) {
LOGGER.info("\t" + stackTraceElement.getClassName() + ":" + stackTraceElement.getLineNumber() + "." + stackTraceElement.getMethodName());
}
LOGGER.info("");
}
LOGGER.info("Done printing stack traces");
LOGGER.info("");
Thread.sleep(10000);
} else if (line.equals("migrate")) {
try {
bimServer.getDatabase().getMigrator().migrate();
bimServer.getServerInfoManager().update();
} catch (MigrationException e) {
LOGGER.error("", e);
} catch (InconsistentModelsException e) {
LOGGER.error("", e);
}
} else if (line.equals("clearendpoints")) {
bimServer.getEndPointManager().clear();
} else if (line.startsWith("showall")) {
KeyValueStore keyValueStore = ((Database) bimServer.getDatabase()).getKeyValueStore();
Set<String> allTableNames = keyValueStore.getAllTableNames();
long total = 0;
for (String tableName : allTableNames) {
long size = keyValueStore.count(tableName);
total += size;
if (size != 0) {
LOGGER.info(tableName + " " + size);
}
}
LOGGER.info("total: " + total);
} else {
LOGGER.info("Unknown command");
}
} catch (IOException e) {
LOGGER.error("", e);
}
}
} catch (InterruptedException e) {
}
}
use of org.bimserver.models.ifc2x3tc1.IfcWall in project BIMserver by opensourceBIM.
the class TestDeleteObjects method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a new project
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
IfcModelInterface model = bimServerClient.newModel(newProject, true);
for (int i = 0; i < 10; i++) {
IfcWall wall = model.create(Ifc2x3tc1Package.eINSTANCE.getIfcWall());
wall.setName("Wall " + i);
wall.setGlobalId("Wall " + i);
}
long roid = model.commit("Initial model");
model = bimServerClient.getModel(newProject, roid, true, true);
List<IfcWall> walls = model.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcWall());
assertTrue(walls.size() == 10);
IfcWall wall6 = (IfcWall) model.getByGuid("Wall 6");
assertTrue(wall6 != null);
wall6.remove();
roid = model.commit("Removed wall 6");
model = bimServerClient.getModel(newProject, roid, true, false);
walls = model.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcWall());
assertTrue(walls.size() == 9);
} catch (Throwable e) {
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
use of org.bimserver.models.ifc2x3tc1.IfcWall in project BIMserver by opensourceBIM.
the class TestChangeGeometryError method test.
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a new project
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), false, true, true);
List<IfcWall> walls = model.getAllWithSubTypes(Ifc2x3tc1Package.eINSTANCE.getIfcWall());
IfcWall firstWall = walls.get(0);
firstWall.getGeometry().getData().setVertices(new byte[10]);
model.commit("Tried to change geometry, which should not be possible");
fail("This have thrown an error");
} catch (Throwable e) {
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
e.printStackTrace();
assertEquals("Only objects from the following schemas are allowed to be changed: Ifc2x3tc1 and IFC4, this object (GeometryData) is from the \"geometry\" package", e.getMessage());
}
}
use of org.bimserver.models.ifc2x3tc1.IfcWall in project BIMserver by opensourceBIM.
the class TestChangeDescription method start.
private void start() {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
try {
SProject project = client.getServiceInterface().getProjectsByName("dfgfgdf").get(0);
IfcModelInterface model = client.getModel(project, project.getLastRevisionId(), false, true);
for (IfcWall wall : model.getAllWithSubTypes(IfcWall.class)) {
wall.setDescription(wall.getDescription() + " Changed");
}
model.commit("test");
} catch (UserException e) {
e.printStackTrace();
} catch (ServerException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
e.printStackTrace();
}
}
use of org.bimserver.models.ifc2x3tc1.IfcWall in project BIMserver by opensourceBIM.
the class TestNewQueryViaClient method start.
private void start() {
try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
String projectName = "Test " + new Random().nextInt();
SProject project = client.getServiceInterface().addProject(projectName, "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
client.checkin(project.getOid(), "Test Model", deserializer.getOid(), false, Flow.SYNC, Paths.get("C:/Git/TestFiles/TestData/data/AC11-FZK-Haus-IFC.ifc"));
project = client.getServiceInterface().getProjectByPoid(project.getOid());
System.out.println(project.getName());
ClientIfcModel model = client.getModel(project, project.getLastRevisionId(), false, false);
Query query = new Query(model.getPackageMetaData());
QueryPart queryPart = query.createQueryPart();
queryPart.addType(Ifc2x3tc1Package.eINSTANCE.getIfcWall(), true);
for (IfcWall ifcWall : model.getAllWithSubTypes(IfcWall.class)) {
System.out.println(ifcWall.getGlobalId());
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (ChannelConnectionException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
e.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
Aggregations