use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class GetLogs method start.
private void start() {
try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory(null, "[ADD]")) {
client = factory.create(new UsernamePasswordAuthenticationInfo("[ADD]", "[ADD]"));
List<SLogAction> logs = client.getAdminInterface().getLogs();
Path file = Paths.get("log.txt");
writer = new PrintWriter(file.toFile());
try {
for (SLogAction sLogAction : logs) {
if (sLogAction instanceof SDatabaseCreated) {
write(sLogAction, "Database created");
} else if (sLogAction instanceof SUserAddedToProject) {
SUserAddedToProject sUserAddedToProject = (SUserAddedToProject) sLogAction;
SProject project = getProject(sUserAddedToProject.getProjectId());
SUser user = getUser(sUserAddedToProject.getUserId());
write(sLogAction, "User " + user.getUsername() + " added to project " + project.getName());
} else if (sLogAction instanceof SUserRemovedFromProject) {
SUserRemovedFromProject sUserRemovedFromProject = (SUserRemovedFromProject) sLogAction;
SProject project = getProject(sUserRemovedFromProject.getProjectId());
SUser user = getUser(sUserRemovedFromProject.getUserId());
write(sLogAction, "User " + user.getUsername() + " removed from project " + project.getName());
} else if (sLogAction instanceof SNewUserAdded) {
SNewUserAdded sNewUserAdded = (SNewUserAdded) sLogAction;
SUser user = getUser(sNewUserAdded.getUserId());
write(sLogAction, "User " + user.getUsername() + " created");
} else if (sLogAction instanceof SNewProjectAdded) {
SNewProjectAdded sNewProject = (SNewProjectAdded) sLogAction;
SProject project = getProject(sNewProject.getProjectId());
write(sLogAction, "Project " + project.getName() + " created");
} else if (sLogAction instanceof SNewRevisionAdded) {
SNewRevisionAdded sNewRevisionAdded = (SNewRevisionAdded) sLogAction;
SProject project = getProject(sNewRevisionAdded.getProjectId());
SRevision revision = getRevision(sNewRevisionAdded.getRevisionId());
write(sLogAction, "Revision " + revision.getId() + " with comment " + revision.getComment() + " added to project " + project.getName());
} else if (sLogAction instanceof SProjectUpdated) {
SProjectUpdated sProjectUpdated = (SProjectUpdated) sLogAction;
SProject project = getProject(sProjectUpdated.getProjectId());
write(sLogAction, "Project " + project.getName() + " updated");
} else if (sLogAction instanceof SProjectDeleted) {
SProjectDeleted sProjectDeleted = (SProjectDeleted) sLogAction;
SProject project = getProject(sProjectDeleted.getProjectId());
write(sLogAction, "Project " + project.getName() + " deleted");
} else if (sLogAction instanceof SUserChanged) {
SUserChanged sUserChanged = (SUserChanged) sLogAction;
SUser user = getUser(sUserChanged.getUserId());
write(sLogAction, "User " + user.getUsername() + " updated");
} else if (sLogAction instanceof SServerStarted) {
write(sLogAction, "Server started");
} else {
write(sLogAction, "NOT IMPL " + sLogAction.getClass().getSimpleName());
}
}
} finally {
writer.close();
}
} catch (ServiceException | ChannelConnectionException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
e.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}
}
use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class RegenerateGeometry method start.
private void start() {
try {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
List<SProject> allProjects = client.getServiceInterface().getAllProjects(false, true);
Set<Long> croids = new HashSet<Long>();
for (SProject project : allProjects) {
for (Long roid : project.getRevisions()) {
SRevision revision = client.getServiceInterface().getRevision(roid);
for (long croid : revision.getConcreteRevisions()) {
croids.add(croid);
}
}
}
for (long croid : croids) {
client.getAdminInterface().regenerateGeometry(croid);
}
System.out.println("Done");
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
}
}
use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class TestUploadSameModelALot method start.
private void start() {
try {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
client.getSettingsInterface().setGenerateGeometryOnCheckin(false);
for (int i = 0; i < 20; i++) {
SProject project = client.getServiceInterface().addProject("P" + i, "ifc2x3tc1");
SDeserializerPluginConfiguration deserializerForExtension = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
System.out.println(i);
client.checkin(project.getOid(), "C" + i, deserializerForExtension.getOid(), false, Flow.SYNC, Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc"));
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.
the class Tmp method main.
public static void main(String[] args) {
BimServerClientInterface bimServerClient = LocalDevSetup.setupJson("http://localhost:8080");
// Create a project
try {
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, Paths.get("../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(), false, false);
System.out.println(model.getAllWithSubTypes(IfcWall.class).size());
} catch (ServerException | UserException | PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (BimServerClientException e) {
e.printStackTrace();
}
}
Aggregations