use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class AllTests method setup.
private static void setup() {
// Create a config
Path home = Paths.get("tmptestdata/home-" + new Random().nextInt(1000000000));
// Remove the home dir if it's there
if (Files.exists(home)) {
try {
PathUtils.removeDirectoryWithContent(home);
} catch (IOException e) {
e.printStackTrace();
}
}
BimServerConfig config = new BimServerConfig();
config.setHomeDir(home);
config.setStartEmbeddedWebServer(true);
config.setPort(7010);
config.setResourceFetcher(new LocalDevelopmentResourceFetcher(Paths.get("../")));
config.setClassPath(System.getProperty("java.class.path"));
bimServer = new BimServer(config);
try {
bimServer.setEmbeddedWebServer(new EmbeddedWebServer(bimServer, Paths.get("."), false));
// CHANGE THESE TO MATCH YOUR CONFIGURATION
// Path[] pluginDirectories = new Path[]{Paths.get("C:\\Git\\IfcPlugins\\IfcPlugins"), Paths.get("C:\\Git\\IfcOpenShell-BIMserver-plugin")};
// Start it
bimServer.start();
// Load plugins
// LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), pluginDirectories);
// Get a client, not using any protocol (direct connection)
BimServerClientInterface client = bimServer.getBimServerClientFactory().create();
// Setup the server
client.getAdminInterface().setup("http://localhost:7010", "Test Name", "Test Description", "noicon", "Administrator", "admin@bimserver.org", "admin");
ServiceMap serviceMap = bimServer.getServiceFactory().get(new SystemAuthorization(1, TimeUnit.HOURS), AccessMethod.INTERNAL);
serviceMap.getSettingsInterface().setCacheOutputFiles(false);
client.disconnect();
client = bimServer.getBimServerClientFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
String pluginsString = System.getProperty("plugins");
if (pluginsString != null) {
String[] plugins = pluginsString.split(";");
Path[] paths = new Path[plugins.length];
int i = 0;
for (String p : plugins) {
paths[i++] = Paths.get(p);
}
LocalDevPluginLoader.loadPlugins(bimServer.getPluginManager(), paths);
} else {
LoggerFactory.getLogger(AllTests.class).info("Installing plugins");
client.getPluginInterface().installPluginBundle("http://archiva.logic-labs.nl/repository/snapshots", "org.opensourcebim", "ifcplugins", null, null);
client.getPluginInterface().installPluginBundle("http://archiva.logic-labs.nl/repository/snapshots", "org.opensourcebim", "binaryserializers", null, null);
client.getPluginInterface().installPluginBundle("http://archiva.logic-labs.nl/repository/snapshots", "org.opensourcebim", "ifcopenshellplugin", null, null);
}
client.disconnect();
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class ImportLargeProject method main.
public static void main(String[] args) {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
try {
Path baseFolder = Paths.get("C:\\Users\\Ruben de Laat\\Documents\\ttt");
ServiceInterface serviceInterface = client.getServiceInterface();
SProject mainProject = serviceInterface.addProject("Tekla Demo Model", "ifc2x3tc1");
SProject architectural = serviceInterface.addProjectAsSubProject("Architectural", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHouseArchitectural = serviceInterface.addProjectAsSubProject("Tekla House Architectural", architectural.getOid(), "ifc2x3tc1");
SProject structuralSteal = serviceInterface.addProjectAsSubProject("Structural Steal", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHouseStructural = serviceInterface.addProjectAsSubProject("Tekla House Structural", structuralSteal.getOid(), "ifc2x3tc1");
SProject foundation = serviceInterface.addProjectAsSubProject("Foundation", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHouseFoundationFootings = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Footings", foundation.getOid(), "ifc2x3tc1");
SProject teklaHouseFoundationPiles = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Piles", foundation.getOid(), "ifc2x3tc1");
SProject teklaHouseFoundationRebars = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Rebars", foundation.getOid(), "ifc2x3tc1");
SProject teklaHouseFoundationEmbedments = serviceInterface.addProjectAsSubProject("Tekla Hose Foundation Embedments", foundation.getOid(), "ifc2x3tc1");
SProject cipConcreteContractor = serviceInterface.addProjectAsSubProject("CIP Concrete Contractor", mainProject.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Tekla House CIP Pours", cipConcreteContractor.getOid(), "ifc2x3tc1");
SProject teklaHouseCIPRebars = serviceInterface.addProjectAsSubProject("Tekla House CIP Rebars", cipConcreteContractor.getOid(), "ifc2x3tc1");
SProject teklaHouseCIPColumns = serviceInterface.addProjectAsSubProject("Tekla House CIP Columns", cipConcreteContractor.getOid(), "ifc2x3tc1");
SProject formWork = serviceInterface.addProjectAsSubProject("Formwork", mainProject.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Column Formwork", formWork.getOid(), "ifc2x3tc1");
SProject precast = serviceInterface.addProjectAsSubProject("Precast", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHousePrecastRebars = serviceInterface.addProjectAsSubProject("Tekla House Precast Rebars", precast.getOid(), "ifc2x3tc1");
SProject teklaHousePrecastConcrete = serviceInterface.addProjectAsSubProject("Tekla House Precast Concrete", precast.getOid(), "ifc2x3tc1");
SProject mep = serviceInterface.addProjectAsSubProject("MEP", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHouseMEPGround = serviceInterface.addProjectAsSubProject("Teklas House MEP, Ground", mep.getOid(), "ifc2x3tc1");
SProject teklaHouseMEP1 = serviceInterface.addProjectAsSubProject("Tekla House MEP, 1st", mep.getOid(), "ifc2x3tc1");
SProject teklaHouseMEP2 = serviceInterface.addProjectAsSubProject("Tekla House MEP, 2nd", mep.getOid(), "ifc2x3tc1");
SProject teklaHouseMEP3 = serviceInterface.addProjectAsSubProject("Tekla House MEP, 3rd", mep.getOid(), "ifc2x3tc1");
SProject teklaHouseMEPRoof = serviceInterface.addProjectAsSubProject("Tekla House MEP, Roof", mep.getOid(), "ifc2x3tc1");
SProject site = serviceInterface.addProjectAsSubProject("Site", mainProject.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Site.skp", site.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Tower crane", site.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Caterpillar", site.getOid(), "ifc2x3tc1");
serviceInterface.addProjectAsSubProject("Excavator", site.getOid(), "ifc2x3tc1");
SProject grid = serviceInterface.addProjectAsSubProject("Grid", mainProject.getOid(), "ifc2x3tc1");
SProject teklaHouseGrids = serviceInterface.addProjectAsSubProject("Tekla House Grids", grid.getOid(), "ifc2x3tc1");
SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", grid.getOid());
client.checkin(teklaHouseStructural.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Structural.ifcZIP"));
client.checkin(teklaHouseGrids.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Grids.ifc"));
client.checkin(teklaHouseFoundationFootings.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Footings.ifcZIP"));
client.checkin(teklaHouseFoundationPiles.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Piles.ifcZIP"));
client.checkin(teklaHouseFoundationRebars.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Rebars.ifcZIP"));
client.checkin(teklaHouseFoundationEmbedments.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Foundation Embedments.ifcZIP"));
client.checkin(teklaHousePrecastRebars.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Precast Rebars.ifcZIP"));
client.checkin(teklaHousePrecastConcrete.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Precast Concrete.ifcZIP"));
// client.checkin(teklaHouseCIPPours.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder, "Tekla House CIP Pours.ifc"));
client.checkin(teklaHouseCIPRebars.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House CIP Rebars.ifcZIP"));
client.checkin(teklaHouseCIPColumns.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House CIP Columns.ifcZIP"));
client.checkin(teklaHouseArchitectural.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House Architectural.ifczip"));
client.checkin(teklaHouseMEPGround.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, Ground.ifc"));
client.checkin(teklaHouseMEP1.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, 1st.ifc"));
client.checkin(teklaHouseMEP2.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, 2nd.ifc"));
client.checkin(teklaHouseMEP3.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, 3rd.ifc"));
client.checkin(teklaHouseMEPRoof.getOid(), "Initial", deserializer.getOid(), false, Flow.SYNC, baseFolder.resolve("Tekla House MEP, Roof.ifc"));
mainProject = serviceInterface.getProjectByPoid(mainProject.getOid());
SSerializerPluginConfiguration serializer = client.getServiceInterface().getSerializerByContentType("application/ifc");
client.download(mainProject.getLastRevisionId(), serializer.getOid(), Paths.get("output.ifc"));
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
e.printStackTrace();
}
}
use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestCreateProperties method test.
@Test
public void test() {
try {
// New client
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a project
SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// Refresh project
project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
// Load model without lazy loading (complete model at once)
IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), true, true);
String propertyName = "BooleanProperty";
int nrWindowsFirst = 0;
// Iterate over all projects, there should be 1
for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
nrWindowsFirst++;
createProperty(window, model, propertyName, "Description of property", true);
}
long newRoid = model.commit("Added boolean properties to " + nrWindowsFirst + " windows");
model = bimServerClient.getModel(project, newRoid, true, false);
int foundOke = 0;
int nrWindowsSecond = 0;
Set<Long> counted = new HashSet<Long>();
for (IfcWindow window : model.getAllWithSubTypes(IfcWindow.class)) {
nrWindowsSecond++;
for (IfcRelDefines ifcRelDefines : window.getIsDefinedBy()) {
if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines;
IfcPropertySetDefinition relatingPropertyDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition();
if (relatingPropertyDefinition instanceof IfcPropertySet) {
IfcPropertySet ifcPropertySet = (IfcPropertySet) relatingPropertyDefinition;
for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) {
if (ifcProperty instanceof IfcPropertySingleValue) {
IfcPropertySingleValue ifcPropertySingleValue = (IfcPropertySingleValue) ifcProperty;
if (ifcPropertySingleValue.getName().equals(propertyName)) {
IfcValue nominalValue = ifcPropertySingleValue.getNominalValue();
if (nominalValue instanceof IfcBoolean) {
if (((IfcBoolean) nominalValue).getWrappedValue() == Tristate.TRUE) {
if (!counted.contains(ifcPropertySingleValue.getOid())) {
foundOke++;
counted.add(ifcPropertySingleValue.getOid());
}
}
}
}
}
}
}
}
}
}
LOGGER.info("Windows first: " + nrWindowsFirst);
LOGGER.info("Windows second: " + nrWindowsSecond);
LOGGER.info("Found Oke: " + foundOke);
if (foundOke != nrWindowsFirst) {
fail(foundOke + " / " + nrWindowsFirst);
}
} catch (Throwable e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.bimserver.plugins.services.BimServerClientInterface 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.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.
the class TestReadProperties method test.
@Test
public void test() {
try {
// New client
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
// Create a project
SProject project = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
// Look for a deserializer
SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
// Checkin file
bimServerClient.checkin(project.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
// Refresh project
project = bimServerClient.getServiceInterface().getProjectByPoid(project.getOid());
// Load model without lazy loading (complete model at once)
IfcModelInterface model = bimServerClient.getModel(project, project.getLastRevisionId(), true, false);
// Iterate over all projects, there should be 1
for (IfcProject ifcProject : model.getAllWithSubTypes(IfcProject.class)) {
for (IfcRelDefines ifcRelDefines : ifcProject.getIsDefinedBy()) {
if (ifcRelDefines instanceof IfcRelDefinesByProperties) {
IfcRelDefinesByProperties ifcRelDefinesByProperties = (IfcRelDefinesByProperties) ifcRelDefines;
IfcPropertySetDefinition relatingPropertyDefinition = ifcRelDefinesByProperties.getRelatingPropertyDefinition();
if (relatingPropertyDefinition instanceof IfcPropertySet) {
IfcPropertySet ifcPropertySet = (IfcPropertySet) relatingPropertyDefinition;
for (IfcProperty ifcProperty : ifcPropertySet.getHasProperties()) {
if (ifcProperty instanceof IfcPropertySingleValue) {
IfcPropertySingleValue ifcPropertySingleValue = (IfcPropertySingleValue) ifcProperty;
IfcValue nominalValue = ifcPropertySingleValue.getNominalValue();
String stringValue = "";
if (nominalValue instanceof IfcLabel) {
stringValue = ((IfcLabel) nominalValue).getWrappedValue();
} else if (nominalValue instanceof IfcIdentifier) {
stringValue = ((IfcIdentifier) nominalValue).getWrappedValue();
} else if (nominalValue instanceof IfcAreaMeasure) {
stringValue = "" + ((IfcAreaMeasure) nominalValue).getWrappedValue();
}
if (ifcPropertySingleValue.getName().equals("ConstructionMode")) {
if (!stringValue.equals("Massivbau")) {
fail("Massivbau expected");
}
} else if (ifcPropertySingleValue.getName().equals("BuildingPermitId")) {
if (!stringValue.equals("4711")) {
fail("4711 expected");
}
} else if (ifcPropertySingleValue.getName().equals("GrossAreaPlanned")) {
if (stringValue == null || !stringValue.equals("1000.0")) {
fail("1000. expected");
}
}
System.out.println(ifcPropertySingleValue.getName() + ": " + stringValue);
}
}
}
}
}
}
} catch (Throwable e) {
if (!(e instanceof AssertionError)) {
fail(e.getMessage());
}
}
}
Aggregations