private void saveAssociations() { logger.debug("saveAssociations()"); final org.zkoss.zk.ui.Desktop desktop = Executions.getCurrent().getDesktop(); if (desktop.isServerPushEnabled() == false) desktop.enableServerPush(true); final EventListener el = this; Clients.showBusy(Labels.getLabel("common.saveChanges") + "..."); final List<CodeSystemEntityVersionAssociation> failureList = new LinkedList<CodeSystemEntityVersionAssociation>(); // Import durchführen Timer timer = new Timer(); timer.schedule( new TimerTask() { @Override public void run() { try { String sFailure = ""; logger.debug( "save associations, count: " + genericList.getListbox().getListModel().getSize()); // save associations // for(Object obj : genericList.getListbox().getListModel()) for (int i = 0; i < genericList.getListbox().getListModel().getSize(); ++i) { GenericListRowType row = (GenericListRowType) genericList.getListbox().getListModel().getElementAt(i); logger.debug("row type: " + row.getData().getClass().getCanonicalName()); if (row.getData() instanceof CodeSystemEntityVersionAssociation) { CodeSystemEntityVersionAssociation cseva = (CodeSystemEntityVersionAssociation) row.getData(); // cseva.getCodeSystemEntityVersionByCodeSystemEntityVersionId1() CreateConceptAssociationRequestType request = new CreateConceptAssociationRequestType(); request.setLoginToken(SessionHelper.getSessionId()); request.setCodeSystemEntityVersionAssociation(cseva); CreateConceptAssociationResponse.Return response = WebServiceHelper.createConceptAssociation(request); logger.debug("result: " + response.getReturnInfos().getMessage()); if (response.getReturnInfos().getStatus() == de.fhdo.terminologie.ws.conceptassociation.Status.FAILURE) { failureList.add(cseva); sFailure = response.getReturnInfos().getMessage(); } } } // Executions.schedule(desktop, el, new Event("finish", null, "")); Executions.activate(desktop); Clients.clearBusy(); List<GenericListRowType> rows = new LinkedList<GenericListRowType>(); for (CodeSystemEntityVersionAssociation cseva : failureList) { rows.add(createRow(cseva)); } genericList.setDataList(rows); // reload side lists (change mapping entries) reloadLists(); if (sFailure.length() > 0) throw new Exception(sFailure); // Messagebox.show(sFailure); Executions.deactivate(desktop); // Executions.schedule(desktop, el, new Event("updateStatus", null, // msg)); } catch (Exception ex) { LoggingOutput.outputException(ex, this); try { Executions.activate(desktop); Clients.clearBusy(); Messagebox.show(ex.getLocalizedMessage()); Executions.deactivate(desktop); } catch (Exception e) { } } } }, 100); }
public void automaticAssociations() { logger.debug("automaticAssociations()"); if (Messagebox.show( Labels.getLabel("common.automaticMsg"), Labels.getLabel("common.automatic"), Messagebox.YES | Messagebox.NO, Messagebox.QUESTION) == Messagebox.YES) { final org.zkoss.zk.ui.Desktop desktop = Executions.getCurrent().getDesktop(); if (desktop.isServerPushEnabled() == false) desktop.enableServerPush(true); Clients.showBusy(Labels.getLabel("loginHelper.working")); final CodeSystem cs1 = (CodeSystem) SessionHelper.getValue("selectedCS1"); final CodeSystem cs2 = (CodeSystem) SessionHelper.getValue("selectedCS2"); // start timer to enable busy message Timer timer = new Timer(); timer.schedule( new TimerTask() { @Override public void run() { try { // List<CodeSystemEntityVersionAssociation> list = new // LinkedList<CodeSystemEntityVersionAssociation>(); logger.debug("cs1: " + cs1.getName()); logger.debug("cs2: " + cs2.getName()); long csvId1 = cs1.getCodeSystemVersions().get(0).getVersionId(); long csvId2 = cs2.getCodeSystemVersions().get(0).getVersionId(); logger.debug("csvId1: " + csvId1); logger.debug("csvId2: " + csvId2); // ListCodeSystemConceptsRequestType ListCodeSystemConceptsResponse.Return response1 = WebServiceHelper.listCodeSystemConcepts(csvId1); ListCodeSystemConceptsResponse.Return response2 = WebServiceHelper.listCodeSystemConcepts(csvId2); logger.debug("result 1: " + response1.getReturnInfos().getMessage()); logger.debug("result 2: " + response2.getReturnInfos().getMessage()); Executions.activate(desktop); if (response1.getReturnInfos().getStatus() == Status.OK && response2.getReturnInfos().getStatus() == Status.OK) { for (CodeSystemEntity cse1 : response1.getCodeSystemEntity()) { CodeSystemEntityVersion csev1 = cse1.getCodeSystemEntityVersions().get(0); CodeSystemConcept csc1 = csev1.getCodeSystemConcepts().get(0); for (CodeSystemEntity cse2 : response2.getCodeSystemEntity()) { CodeSystemEntityVersion csev2 = cse2.getCodeSystemEntityVersions().get(0); CodeSystemConcept csc2 = csev2.getCodeSystemConcepts().get(0); // check same code if (csc1.getCode().equals(csc2.getCode())) { // match addAutomaticMatch(csev1, csev2); } // check containing text if (csc1.getTerm().toLowerCase().contains(csc2.getTerm().toLowerCase())) { addAutomaticMatch(csev1, csev2); } if (csc2.getTerm().toLowerCase().contains(csc1.getTerm().toLowerCase())) { addAutomaticMatch(csev2, csev1); } } } } // read data of both codesystems /*Include incL = (Include) getFellow("incContentLeft"); ContentAssociationEditor contentEditor1 = (ContentAssociationEditor)incL.getDynamicProperty("instance"); Include incR = (Include) getFellow("incContentRight"); ContentAssociationEditor contentEditor2 = (ContentAssociationEditor)incL.getDynamicProperty("instance"); ContentConcepts content1 = contentEditor1.getContent(); ContentConcepts content2 = contentEditor2.getContent(); TreeModel model1 = content1.getConcepts().getTreeConcepts().getModel(); logger.debug("root: " + model1.getRoot().getClass().getCanonicalName());*/ // Executions.schedule(desktop, el, new Event("finish", null, "")); Clients.clearBusy(); Executions.deactivate(desktop); } catch (Exception ex) { LoggingOutput.outputException(ex, this); try { Executions.activate(desktop); Clients.clearBusy(); Messagebox.show(ex.getLocalizedMessage()); Executions.deactivate(desktop); } catch (Exception e) { } } } }, 10); } }