use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class GetLogs method getProject.
private SProject getProject(long poid) throws ServerException, UserException, PublicInterfaceNotFoundException {
SProject project = projects.get(poid);
if (project == null) {
project = client.getServiceInterface().getProjectByPoid(poid);
projects.put(poid, project);
}
return project;
}
use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class TestBigModelEmf method test.
@Test
public void test() {
try {
BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
IfcModelInterface model = bimServerClient.newModel(newProject, true);
RichIfcModel richIfcModel = new RichIfcModel(model);
IfcBuilding ifcBuilding = richIfcModel.createDefaultProjectStructure();
IfcRelAggregates buildingAggregation = richIfcModel.create(IfcRelAggregates.class);
buildingAggregation.setRelatingObject(ifcBuilding);
for (int i = 1; i <= 10; i++) {
IfcBuildingStorey ifcBuildingStorey = richIfcModel.create(IfcBuildingStorey.class);
ifcBuildingStorey.setName("Storey " + i);
ifcBuildingStorey.setCompositionType(IfcElementCompositionEnum.ELEMENT);
ifcBuildingStorey.setElevation(3000 * i);
IfcLocalPlacement storeyPlacement = richIfcModel.create(IfcLocalPlacement.class);
storeyPlacement.setRelativePlacement(richIfcModel.createBasicPosition(0, 0, i * 3000));
ifcBuildingStorey.setObjectPlacement(storeyPlacement);
buildingAggregation.getRelatedObjects().add(ifcBuildingStorey);
IfcRelAggregates storeyAggregation = richIfcModel.create(IfcRelAggregates.class);
storeyAggregation.setRelatingObject(ifcBuildingStorey);
for (int x = 1; x <= 10; x++) {
for (int y = 1; y <= 10; y++) {
createSpace(richIfcModel, richIfcModel.getDefaultRepresentationContext(), storeyPlacement, storeyAggregation, x, y);
}
}
}
long roid = model.commit("Initial model");
SSerializerPluginConfiguration serializerByContentType = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1 (Streaming)");
bimServerClient.download(roid, serializerByContentType.getOid(), new FileOutputStream(new File("created.ifc")));
} 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 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.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class TestConstantlyDownloading method main.
public static void main(String[] args) {
long poid = 196609;
try {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
for (int i = 0; i < 200; i++) {
SProject project = client.getServiceInterface().getProjectByPoid(poid);
long roid = project.getLastRevisionId();
SSerializerPluginConfiguration serializer = client.getPluginInterface().getSerializerByPluginClassName("org.bimserver.geometry.json.JsonGeometrySerializerPlugin");
System.out.println(i);
client.download(roid, serializer.getOid(), new ByteArrayOutputStream());
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class SyndicationServlet method writeCheckoutsFeed.
private void writeCheckoutsFeed(HttpServletRequest request, HttpServletResponse response, ServiceMap serviceMap) throws ServiceException, IOException, FeedException, PublicInterfaceNotFoundException {
long poid = Long.parseLong(request.getParameter("poid"));
SProject sProject = serviceMap.getServiceInterface().getProjectByPoid(poid);
SyndFeed feed = new SyndFeedImpl();
feed.setFeedType(FEED_TYPE);
feed.setTitle("BIMserver.org checkouts feed for project '" + sProject.getName() + "'");
feed.setLink(request.getContextPath());
feed.setDescription("This feed represents all the checkouts of project '" + sProject.getName() + "'");
List<SyndEntry> entries = new ArrayList<SyndEntry>();
try {
List<SCheckout> allCheckoutsOfProject = serviceMap.getServiceInterface().getAllCheckoutsOfProjectAndSubProjects(poid);
for (SCheckout sCheckout : allCheckoutsOfProject) {
SRevision revision = serviceMap.getServiceInterface().getRevision(sCheckout.getRevision().getOid());
SProject project = serviceMap.getServiceInterface().getProjectByPoid(sCheckout.getProjectId());
SUser user = serviceMap.getServiceInterface().getUserByUoid(sCheckout.getUserId());
SyndEntry entry = new SyndEntryImpl();
entry.setTitle("Checkout on " + project.getName() + ", revision " + revision.getId());
entry.setLink(request.getContextPath() + "/project.jsp?poid=" + sProject.getOid());
entry.setPublishedDate(sCheckout.getDate());
SyndContent description = new SyndContentImpl();
description.setType("text/plain");
description.setValue("<table><tr><td>User</td><td>" + user.getUsername() + "</td></tr><tr><td>Revision</td><td>" + sCheckout.getRevision().getOid() + "</td></tr></table>");
entry.setDescription(description);
entries.add(entry);
}
} catch (UserException e) {
LOGGER.error("", e);
}
feed.setEntries(entries);
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, response.getWriter());
}
Aggregations