use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class TestReadTrim 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");
// Get the appropriate deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
// Checkin the file
bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/TST.ifc"));
// Refresh project info
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, false);
for (IfcTrimmedCurve ifcTrimmedCurve : model.getAllWithSubTypes(IfcTrimmedCurve.class)) {
for (IfcTrimmingSelect ifcTrimmingSelect : ifcTrimmedCurve.getTrim1()) {
if (ifcTrimmingSelect instanceof IfcParameterValue) {
IfcParameterValue ifcParameterValue = (IfcParameterValue) ifcTrimmingSelect;
System.out.println("Trim1: " + ifcParameterValue.getWrappedValue());
}
}
for (IfcTrimmingSelect ifcTrimmingSelect : ifcTrimmedCurve.getTrim2()) {
if (ifcTrimmingSelect instanceof IfcParameterValue) {
IfcParameterValue ifcParameterValue = (IfcParameterValue) ifcTrimmingSelect;
System.out.println("Trim2: " + ifcParameterValue.getWrappedValue());
}
}
}
} catch (Throwable e) {
e.printStackTrace();
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class TestRemoveReferenceList method test.
// This test makes no sense, since getContainedInStructure is a Set (unordered)
@Test
public void test() {
try {
// Create a new BimServerClient with authentication
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Get the service interface
bimServerClient.getSettingsInterface().setGenerateGeometryOnCheckin(false);
// Create a new project
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
IfcModelInterface model = bimServerClient.newModel(newProject, true);
IfcFurnishingElement furnishingElement = model.create(IfcFurnishingElement.class);
furnishingElement.setName("Furnishing 1");
IfcRelContainedInSpatialStructure link1 = model.create(IfcRelContainedInSpatialStructure.class);
link1.setName("link1");
IfcRelContainedInSpatialStructure link2 = model.create(IfcRelContainedInSpatialStructure.class);
link2.setName("link2");
IfcRelContainedInSpatialStructure link3 = model.create(IfcRelContainedInSpatialStructure.class);
link3.setName("link3");
link1.getRelatedElements().add(furnishingElement);
link2.getRelatedElements().add(furnishingElement);
link3.getRelatedElements().add(furnishingElement);
model.commit("initial");
// refresh
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
bimServerClient.download(newProject.getLastRevisionId(), bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc").getOid(), Paths.get("testX.ifc"));
model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, true);
for (IfcFurnishingElement ifcFurnishingElement : model.getAll(IfcFurnishingElement.class)) {
if (ifcFurnishingElement.getContainedInStructure().size() != 3) {
fail("Size should be 3, is " + ifcFurnishingElement.getContainedInStructure().size());
}
// Remove the middle one
IfcRelContainedInSpatialStructure middleOne = null;
for (IfcRelContainedInSpatialStructure rel : ifcFurnishingElement.getContainedInStructure()) {
if (rel.getName().equals("link2")) {
middleOne = rel;
break;
}
}
ifcFurnishingElement.getContainedInStructure().remove(middleOne);
}
model.commit("removed middle link");
// refresh
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, false);
for (IfcFurnishingElement ifcFurnishingElement : model.getAll(IfcFurnishingElement.class)) {
assertTrue("Size should be 2, is " + ifcFurnishingElement.getContainedInStructure().size(), ifcFurnishingElement.getContainedInStructure().size() == 2);
assertEquals("link", "link1", ifcFurnishingElement.getContainedInStructure().get(0).getName());
assertEquals("link", "link3", ifcFurnishingElement.getContainedInStructure().get(1).getName());
}
} catch (Throwable e) {
e.printStackTrace();
if (e instanceof AssertionError) {
throw (AssertionError) e;
}
fail(e.getMessage());
}
}
use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class TestJapaneseChars method test.
public void test(URL url, String expectedMessage) {
try {
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Find a deserializer to use
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
bimServerClient.checkin(newProject.getOid(), "initial", deserializer.getOid(), false, Flow.SYNC, url);
newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByContentType("application/ifc");
bimServerClient.download(newProject.getLastRevisionId(), serializer.getOid(), Paths.get("bimserver_" + url.getFile().substring(url.getFile().lastIndexOf("/") + 1)));
} catch (Exception e) {
e.printStackTrace();
Assert.assertEquals(expectedMessage, e.getMessage());
}
}
use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class TestInOut method start.
private void start(String[] args) {
BimServerConfig config = new BimServerConfig();
Path homeDir = Paths.get("home");
try {
if (Files.isDirectory(homeDir)) {
PathUtils.removeDirectoryWithContent(homeDir);
}
} catch (IOException e) {
e.printStackTrace();
}
config.setClassPath(System.getProperty("java.class.path"));
config.setHomeDir(homeDir);
config.setPort(8080);
config.setStartEmbeddedWebServer(true);
config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
BimServer bimServer = new BimServer(config);
try {
LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), new OptionsParser(args).getPluginDirectories());
bimServer.start();
if (bimServer.getServerInfo().getServerState() == ServerState.NOT_SETUP) {
AdminInterface adminInterface = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL).get(AdminInterface.class);
adminInterface.setup("http://localhost:8080", "Administrator", "admin@bimserver.org", "admin", null, null, null);
SettingsInterface settingsInterface = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL).get(SettingsInterface.class);
settingsInterface.setCacheOutputFiles(false);
}
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
SProject project = client.getServiceInterface().addProject("test", "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
Path inputFile = Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc");
client.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, inputFile);
project = client.getServiceInterface().getProjectByPoid(project.getOid());
SSerializerPluginConfiguration serializer = client.getServiceInterface().getSerializerByContentType("application/ifc");
Path outputFile = Paths.get("output.ifc");
client.download(project.getLastRevisionId(), serializer.getOid(), outputFile);
Diff diff = new Diff(false, false, false, inputFile, outputFile);
diff.start();
} catch (ServerException e) {
e.printStackTrace();
} catch (DatabaseInitException e) {
e.printStackTrace();
} catch (BimserverDatabaseException e) {
e.printStackTrace();
} catch (PluginException e) {
e.printStackTrace();
} catch (DatabaseRestartRequiredException e) {
e.printStackTrace();
} catch (UserException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (CompareException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
e.printStackTrace();
}
}
use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class TestManyRevisions method start.
private void start(String[] args) {
try {
Path home = Paths.get("home");
PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
MetaDataManager metaDataManager = new MetaDataManager(home.resolve("tmp"));
pluginManager.setMetaDataManager(metaDataManager);
try (BimServerClientFactory factory = new JsonBimServerClientFactory(metaDataManager, "http://localhost:8080")) {
BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
try {
SProject project = client.getServiceInterface().addProject("lots2", "ifc2x3tc1");
Path[] files = new Path[] { Paths.get("../TestData/data/AC11-Institute-Var-2-IFC.ifc"), Paths.get("../TestData/data/AC11-FZK-Haus-IFC - Alt.ifc") };
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
int fn = 0;
for (int i = 0; i < 20; i++) {
System.out.println(i + ": " + files[fn].getFileName().toString());
client.checkin(project.getOid(), "comment" + i, deserializer.getOid(), false, Flow.SYNC, files[fn]);
fn = 1 - fn;
}
} catch (ServerException | UserException | PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations