private void waitForDonePreparing(long topicId) throws UserException, ServerException, PublicInterfaceNotFoundException { for (int i = 0; i < 10; i++) { SLongActionState progress = bimServerClient.getRegistry().getProgress(topicId); if (progress != null) { if (progress.getTitle() != null && progress.getTitle().equals("Done preparing")) { break; } else if (progress.getState() == SActionState.AS_ERROR) { throw new UserException(Joiner.on(", ").join(progress.getErrors())); } } try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } } }
/** * Update progress * @param progress Between 0 and 100 inclusive */ public void updateProgress(int progress) { SLongActionState state = new SLongActionState(); state.setProgress(progress); state.setTitle(name); state.setState(SActionState.FINISHED); state.setStart(startDate); state.setEnd(new Date()); try { bimServerClientInterface.getRegistry().updateProgressTopic(topicId, state); } catch (UserException e) { LOGGER.error("", e); } catch (ServerException e) { LOGGER.error("", e); } catch (PublicInterfaceNotFoundException e) { LOGGER.error("", e); } }
public LongActionState convertFromSObject(SLongActionState input, LongActionState result, DatabaseSession session) throws BimserverDatabaseException { if (input == null) { return null; } if (input instanceof SLongCheckinActionState) { return convertFromSObject((SLongCheckinActionState)input, session); } result.setStart(input.getStart()); result.setEnd(input.getEnd()); result.setProgress(input.getProgress()); result.setState(ActionState.values()[input.getState().ordinal()]); result.setTitle(input.getTitle()); result.setStage(input.getStage()); result.getErrors().addAll(input.getErrors()); result.getWarnings().addAll(input.getWarnings()); result.getInfos().addAll(input.getInfos()); result.setTopicId(input.getTopicId()); return result; } public SServerState convertToSObject(ServerState input) {
public SLongActionState convertToSObject(LongActionState input) { if (input == null) { return null; } if (input instanceof LongCheckinActionState) { return convertToSObject((LongCheckinActionState)input); } SLongActionState result = new SLongActionState(); result.setOid(input.getOid()); result.setRid(input.getRid()); result.setStart(input.getStart()); result.setEnd(input.getEnd()); result.setProgress(input.getProgress()); result.setState(SActionState.values()[input.getState().ordinal()]); result.setTitle(input.getTitle()); result.setStage(input.getStage()); result.getErrors().addAll(input.getErrors()); result.getWarnings().addAll(input.getWarnings()); result.getInfos().addAll(input.getInfos()); result.setTopicId(input.getTopicId()); return result; }
public void download(long roid, long serializerOid, OutputStream outputStream) throws BimServerClientException { try { Long topicId = getServiceInterface().download(Collections.singleton(roid), DefaultQueries.allAsString(), serializerOid, false); SLongActionState progress = getNotificationRegistryInterface().getProgress(topicId); if (progress != null && progress.getState() == SActionState.AS_ERROR) { throw new BimServerClientException(Joiner.on(", ").join(progress.getErrors())); } else { InputStream inputStream = getDownloadData(topicId); try { IOUtils.copy(inputStream, outputStream); getServiceInterface().cleanupLongAction(topicId); } finally { inputStream.close(); } } } catch (ServerException e) { LOGGER.error("", e); } catch (UserException e) { LOGGER.error("", e); } catch (IOException e) { LOGGER.error("", e); } catch (PublicInterfaceNotFoundException e) { LOGGER.error("", e); } }
public LongActionState convertFromSObject(SLongActionState input, DatabaseSession session) throws BimserverDatabaseException { if (session == null) { throw new BimserverDatabaseException("session == null, use the other method"); } LOGGER.info("Potential unlinked object created"); LongActionState result = convertFromSObject(input, StoreFactory.eINSTANCE.createLongActionState(), session); ((IdEObjectImpl)result).setOid(input.getOid()); ((IdEObjectImpl)result).setRid(input.getRid()); return result; }
public Object newInstance() { return new org.bimserver.interfaces.objects.SLongActionState(); } }));
public Object sGet(SField sField) { if (sField.getName().equals("start")) { return getStart(); return getEnd(); return getProgress(); return getState(); return getTitle(); return getStage(); return getErrors(); return getWarnings(); return getInfos(); return getTopicId(); return getOid(); return getRid();
RunningService runningService = new RunningService(topicId, bimServerClientInterface, pluginConfiguration, bimServerClientInterface.getAuthInterface().getLoggedInUser().getUsername()); try { SLongActionState state = new SLongActionState(); state.setProgress(getProgressType() == ProgressType.KNOWN ? 0 : -1); state.setTitle(name); state.setState(SActionState.STARTED); state.setStart(runningService.getStartDate()); bimServerClientInterface.getRegistry().updateProgressTopic(topicId, state); state = new SLongActionState(); state.setProgress(100); state.setTitle(name); state.setState(SActionState.FINISHED); state.setStart(runningService.getStartDate()); state.setEnd(new Date()); bimServerClientInterface.getRegistry().updateProgressTopic(topicId, state); } catch (BimServerClientException e) {