use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException in project BIMserver by opensourceBIM.
the class BimServerImporter method start.
public void start() {
try (BimServerClientFactory factory = new JsonBimServerClientFactory(bimServer.getMetaDataManager(), address)) {
LOGGER.info("Importing...");
remoteClient = factory.create(new UsernamePasswordAuthenticationInfo(username, password));
final BimDatabase database = bimServer.getDatabase();
DatabaseSession databaseSession = database.createSession(OperationType.POSSIBLY_WRITE);
try {
LOGGER.info("Users...");
for (SUser user : remoteClient.getServiceInterface().getAllUsers()) {
createUser(databaseSession, user.getOid());
}
LOGGER.info("Projects...");
for (SProject project : remoteClient.getServiceInterface().getAllProjects(false, false)) {
createProject(databaseSession, project.getOid());
}
LOGGER.info("Done");
databaseSession.commit();
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} finally {
databaseSession.close();
}
final BimServerClientInterface client = bimServer.getBimServerClientFactory().create(new UsernamePasswordAuthenticationInfo(username, password));
// for (SRenderEnginePluginConfiguration renderEnginePluginConfiguration : client.getPluginInterface().getAllRenderEngines(true)) {
// if (renderEnginePluginConfiguration.getName().equals("IFC Engine DLL")) {
// client.getPluginInterface().setDefaultRenderEngine(renderEnginePluginConfiguration.getOid());
// }
// }
Path incoming = Paths.get(path);
final Map<GregorianCalendar, Key> comments = new TreeMap<>();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss");
for (SProject project : remoteClient.getServiceInterface().getAllProjects(false, false)) {
for (SRevision revision : remoteClient.getServiceInterface().getAllRevisionsOfProject(project.getOid())) {
GregorianCalendar gregorianCalendar = new GregorianCalendar();
gregorianCalendar.setTime(revision.getDate());
if (!revision.getComment().startsWith("generated for")) {
User user = users.get(revision.getUserId());
Path userFolder = incoming.resolve(user.getUsername());
boolean found = false;
for (Path file : PathUtils.list(userFolder)) {
if (file.getFileName().toString().endsWith(revision.getComment())) {
String dateStr = file.getFileName().toString().substring(0, 19);
Date parse = dateFormat.parse(dateStr);
GregorianCalendar fileDate = new GregorianCalendar();
fileDate.setTime(parse);
long millisDiff = Math.abs(fileDate.getTimeInMillis() - revision.getDate().getTime());
if (millisDiff > 1000 * 60 * 120) {
// 120 minutes
continue;
}
if (revision.getOid() == project.getLastRevisionId()) {
comments.put(gregorianCalendar, new Key(file, project.getOid(), revision.getComment(), revision.getDate(), revision.getUserId()));
}
found = true;
break;
}
}
if (!found) {
LOGGER.info("Not found: " + revision.getComment());
}
}
}
}
ExecutorService executorService = new ThreadPoolExecutor(1, 1, 1, TimeUnit.DAYS, new ArrayBlockingQueue<Runnable>(1000));
for (final GregorianCalendar gregorianCalendar : comments.keySet()) {
executorService.submit(new Runnable() {
@Override
public void run() {
Key key = comments.get(gregorianCalendar);
LOGGER.info("Checking in: " + key.file.getFileName().toString() + " " + Formatters.bytesToString(key.file.toFile().length()));
Project sProject = projects.get(key.poid);
try {
SDeserializerPluginConfiguration desserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", sProject.getOid());
client.checkinSync(sProject.getOid(), key.comment, desserializer.getOid(), false, key.file);
SProject updatedProject = client.getServiceInterface().getProjectByPoid(sProject.getOid());
DatabaseSession databaseSession = database.createSession(OperationType.POSSIBLY_WRITE);
try {
LOGGER.info("Done");
Project project = databaseSession.get(updatedProject.getOid(), OldQuery.getDefault());
Revision revision = project.getLastRevision();
User user = (User) databaseSession.get(users.get(key.userId).getOid(), OldQuery.getDefault());
for (Revision otherRevision : revision.getConcreteRevisions().get(0).getRevisions()) {
otherRevision.load();
otherRevision.setDate(key.date);
otherRevision.setComment(otherRevision.getComment().replace("Administrator", user.getName()));
databaseSession.store(otherRevision);
}
DateFormat m = new SimpleDateFormat("dd-MM-yyyy");
LOGGER.info("Setting date to " + m.format(key.date));
revision.setUser(user);
revision.setDate(key.date);
databaseSession.store(revision);
databaseSession.commit();
} catch (BimserverDatabaseException | ServiceException e) {
LOGGER.error("", e);
} finally {
databaseSession.close();
}
} catch (IOException | UserException | ServerException | PublicInterfaceNotFoundException e) {
LOGGER.error("", e);
}
}
});
}
executorService.shutdown();
} catch (ServiceException e) {
LOGGER.error("", e);
} catch (ChannelConnectionException e) {
LOGGER.error("", e);
} catch (PublicInterfaceNotFoundException e) {
LOGGER.error("", e);
} catch (ParseException e) {
LOGGER.error("", e);
} catch (IOException e) {
LOGGER.error("", e);
} catch (BimServerClientException e1) {
LOGGER.error("", e1);
} catch (Exception e2) {
LOGGER.error("", e2);
}
}
use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException in project BIMserver by opensourceBIM.
the class AsyncTestAddExtendedData2 method start.
private void start() {
try {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
SFile file = new SFile();
file.setData("test".getBytes(Charsets.UTF_8));
file.setMime("text");
file.setFilename("test.txt");
long fileId = client.getServiceInterface().uploadFile(file);
SProject project = client.getServiceInterface().addProject(RandomUtils.nextInt(1, 100000000) + "", "ifc2x3tc1");
SDeserializerPluginConfiguration deserializerForExtension = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
long topicId = client.getServiceInterface().initiateCheckin(project.getOid(), deserializerForExtension.getOid());
client.checkinAsync(project.getOid(), "initial", deserializerForExtension.getOid(), false, Paths.get("C:\\Git\\TestFiles\\TestData\\data\\AC11-FZK-Haus-IFC.ifc"), topicId);
while (true) {
SLongCheckinActionState progress = (SLongCheckinActionState) client.getNotificationRegistryInterface().getProgress(topicId);
System.out.println(progress.getState());
if (progress.getState() == SActionState.FINISHED) {
SExtendedDataSchema extendedDataSchemaByNamespace = client.getServiceInterface().getExtendedDataSchemaByName("GEOMETRY_GENERATION_REPORT_JSON_1_1");
SExtendedData extendedData = new SExtendedData();
extendedData.setFileId(fileId);
extendedData.setTitle("test3");
extendedData.setSchemaId(extendedDataSchemaByNamespace.getOid());
client.getServiceInterface().addExtendedDataToRevision(progress.getRoid(), extendedData);
break;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException 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.getPluginBundleManager(), 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.checkinSync(project.getOid(), "test", deserializer.getOid(), false, 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.shared.exceptions.PublicInterfaceNotFoundException 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.checkinSync(project.getOid(), "comment" + i, deserializer.getOid(), false, files[fn]);
fn = 1 - fn;
}
} catch (ServerException | UserException | PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.bimserver.shared.exceptions.PublicInterfaceNotFoundException 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.checkinSync(teklaHouseStructural.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House Structural.ifcZIP"));
client.checkinSync(teklaHouseGrids.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House Grids.ifc"));
client.checkinSync(teklaHouseFoundationFootings.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House Foundation Footings.ifcZIP"));
client.checkinSync(teklaHouseFoundationPiles.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House Foundation Piles.ifcZIP"));
client.checkinSync(teklaHouseFoundationRebars.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House Foundation Rebars.ifcZIP"));
client.checkinSync(teklaHouseFoundationEmbedments.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House Foundation Embedments.ifcZIP"));
client.checkinSync(teklaHousePrecastRebars.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House Precast Rebars.ifcZIP"));
client.checkinSync(teklaHousePrecastConcrete.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House Precast Concrete.ifcZIP"));
// client.checkinSync(teklaHouseCIPPours.getOid(), "Initial", deserializer.getOid(), false, true, baseFolder, "Tekla House CIP Pours.ifc"));
client.checkinSync(teklaHouseCIPRebars.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House CIP Rebars.ifcZIP"));
client.checkinSync(teklaHouseCIPColumns.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House CIP Columns.ifcZIP"));
client.checkinSync(teklaHouseArchitectural.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House Architectural.ifczip"));
client.checkinSync(teklaHouseMEPGround.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House MEP, Ground.ifc"));
client.checkinSync(teklaHouseMEP1.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House MEP, 1st.ifc"));
client.checkinSync(teklaHouseMEP2.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House MEP, 2nd.ifc"));
client.checkinSync(teklaHouseMEP3.getOid(), "Initial", deserializer.getOid(), false, baseFolder.resolve("Tekla House MEP, 3rd.ifc"));
client.checkinSync(teklaHouseMEPRoof.getOid(), "Initial", deserializer.getOid(), false, 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();
}
}
Aggregations