コード例 #1
0
 @Override
 public void setConcept(int conceptNid) {
   try {
     setConcept(
         ExtendedAppContext.getDataStore()
             .getConceptVersion(WBUtility.getViewCoordinate(), conceptNid));
   } catch (IOException e) {
     String title = "Unexpected error loading concept with Nid " + conceptNid;
     String msg = e.getClass().getName();
     logger.error(title, e);
     AppContext.getCommonDialogs().showErrorDialog(title, msg, e.getMessage());
   }
 }
コード例 #2
0
  @FXML
  void initialize() {
    assert claimTasksButton != null
        : "fx:id=\"claimTasksButton\" was not injected: check your FXML file 'WorkflowInbox.fxml'.";
    assert synchronizeButton != null
        : "fx:id=\"synchronizeButton\" was not injected: check your FXML file 'WorkflowInbox.fxml'.";
    assert userName != null
        : "fx:id=\"userName\" was not injected: check your FXML file 'WorkflowInbox.fxml'.";
    assert taskTable != null
        : "fx:id=\"taskTable\" was not injected: check your FXML file 'WorkflowInbox.fxml'.";

    userName.setText(user);

    taskTable.setTableMenuButtonVisible(true);

    // BEGIN Task name
    TableColumn<LocalTask, String> tCol = new TableColumn<>();
    tCol.setText("Task");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getName());
        });
    taskTable.getColumns().add(tCol);
    // END Task name

    // BEGIN Task id
    tCol = new TableColumn<>();
    tCol.setText("id");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getId() + "");
        });
    taskTable.getColumns().add(tCol);
    // END Task id

    // BEGIN Component name
    tCol = new TableColumn<>();
    tCol.setText("Component");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getComponentName());
        });
    taskTable.getColumns().add(tCol);
    // END Component name

    // BEGIN WorkflowAction
    tCol = new TableColumn<>();
    tCol.setText("Action");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getAction().toString());
        });
    tCol.setVisible(false);
    taskTable.getColumns().add(tCol);
    // END WorkflowAction

    // BEGIN TaskActionStatus
    tCol = new TableColumn<>();
    tCol.setText("Action Status");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getActionStatus().name());
        });
    tCol.setVisible(false);
    taskTable.getColumns().add(tCol);
    // END TaskActionStatus

    // BEGIN Owner
    tCol = new TableColumn<>();
    tCol.setText("Owner");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getOwner());
        });
    tCol.setVisible(false);
    taskTable.getColumns().add(tCol);
    // END Owner

    // BEGIN Status
    tCol = new TableColumn<>();
    tCol.setText("Status");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getStatus().name());
        });
    tCol.setVisible(false);
    taskTable.getColumns().add(tCol);
    // END Status

    // BEGIN Component id (hidden)
    tCol = new TableColumn<>();
    tCol.setText("Component Id");
    tCol.setCellValueFactory(
        (value) -> {
          return new SimpleStringProperty(value.getValue().getComponentId());
        });
    tCol.setVisible(false);
    taskTable.getColumns().add(tCol);
    // END Component id (hidden)

    // BEGIN Concept
    TableColumn<LocalTask, SimpleDisplayConcept> conceptCol = new TableColumn<>();
    conceptCol.setText("Concept");
    conceptCol.setCellValueFactory(
        (value) -> {
          if (value.getValue().getComponentId() == null) {
            LOG.error("Component ID for task {} is null", value.getValue().getId());

            return new SimpleObjectProperty<SimpleDisplayConcept>();
          }
          UUID componentUuid = null;
          try {
            componentUuid = UUID.fromString(value.getValue().getComponentId());
          } catch (IllegalArgumentException e) {
            LOG.error("Component ID for task {} is not a valid UUID", value.getValue().getId());

            return new SimpleObjectProperty<SimpleDisplayConcept>();
          }

          ConceptVersionBI containingConcept = null;
          ComponentChronicleBI componentChronicle = WBUtility.getComponentChronicle(componentUuid);
          if (componentChronicle == null) {
            LOG.warn(
                "Component ID for task "
                    + value.getValue().getId()
                    + " retrieved a null componentChronicle");

            containingConcept = WBUtility.getConceptVersion(componentUuid);
            if (containingConcept == null) {
              LOG.error(
                  "Component ID for task "
                      + value.getValue().getId()
                      + " retrieved a null concept");

              return new SimpleObjectProperty<SimpleDisplayConcept>();
            }
          } else {
            try {
              containingConcept =
                  componentChronicle
                      .getEnclosingConcept()
                      .getVersion(WBUtility.getViewCoordinate());
            } catch (Exception e) {
              LOG.error(
                  "Failed getting version from ComponentChronicleBI task "
                      + value.getValue().getId()
                      + ".  Caught "
                      + e.getClass().getName()
                      + " "
                      + e.getLocalizedMessage());
              e.printStackTrace();
            }
            if (containingConcept == null) {
              LOG.error(
                  "ComponentChronicleBI task "
                      + value.getValue().getId()
                      + " contained a null enclosing concept");

              return new SimpleObjectProperty<SimpleDisplayConcept>();
            }
          }

          if (componentChronicle == null) {
            LOG.warn(
                "Component id "
                    + componentUuid
                    + " for task "
                    + value.getValue().getId()
                    + " is a concept, not just a component.");
          }
          SimpleDisplayConcept displayConcept = new SimpleDisplayConcept(containingConcept);
          return new SimpleObjectProperty<SimpleDisplayConcept>(displayConcept);
        });
    taskTable.getColumns().add(conceptCol);
    // END concept

    // BEGIN Concept
    TableColumn<LocalTask, String> conceptIdCol = new TableColumn<>();
    conceptIdCol.setText("Concept Id");
    conceptIdCol.setCellValueFactory(
        (value) -> {
          if (value.getValue().getComponentId() == null) {
            LOG.error("Component ID for task {} is null", value.getValue().getId());

            return new SimpleStringProperty();
          }
          UUID componentUuid = null;
          try {
            componentUuid = UUID.fromString(value.getValue().getComponentId());
          } catch (IllegalArgumentException e) {
            LOG.error("Component ID for task {} is not a valid UUID", value.getValue().getId());

            return new SimpleStringProperty();
          }

          ConceptVersionBI containingConcept = null;
          ComponentChronicleBI componentChronicle = WBUtility.getComponentChronicle(componentUuid);
          if (componentChronicle == null) {
            LOG.warn(
                "Component ID for task "
                    + value.getValue().getId()
                    + " retrieved a null componentChronicle");

            containingConcept = WBUtility.getConceptVersion(componentUuid);
            if (containingConcept == null) {
              LOG.error(
                  "Component ID for task "
                      + value.getValue().getId()
                      + " retrieved a null concept");

              return new SimpleStringProperty();
            }
          } else {
            try {
              containingConcept =
                  componentChronicle
                      .getEnclosingConcept()
                      .getVersion(WBUtility.getViewCoordinate());
            } catch (Exception e) {
              LOG.error(
                  "Failed getting version from ComponentChronicleBI task "
                      + value.getValue().getId()
                      + ".  Caught "
                      + e.getClass().getName()
                      + " "
                      + e.getLocalizedMessage());
              e.printStackTrace();
            }

            if (containingConcept == null) {
              LOG.error(
                  "ComponentChronicleBI task "
                      + value.getValue().getId()
                      + " contained a null enclosing concept");

              return new SimpleStringProperty();
            }
          }

          if (componentChronicle == null) {
            LOG.warn(
                "Component id "
                    + componentUuid
                    + " for task "
                    + value.getValue().getId()
                    + " is a concept, not just a component.");
          }

          UUID uuid = containingConcept.getPrimordialUuid();
          return new SimpleStringProperty(uuid.toString());
        });
    conceptIdCol.setVisible(false);
    taskTable.getColumns().add(conceptIdCol);
    // END concept ID

    float colWidth = 1.0f / taskTable.getColumns().size();
    for (TableColumn<LocalTask, ?> col : taskTable.getColumns()) {
      col.prefWidthProperty().bind(taskTable.widthProperty().multiply(colWidth).subtract(3.0));
      col.setCellFactory(new MyCellFactoryCallback<>());
    }

    claimTasksButton.setOnAction(
        (action) -> {
          claimTasksButton.setDisable(true);
          final BusyPopover claimPopover =
              BusyPopover.createBusyPopover("Claiming new tasks...", claimTasksButton);

          Utility.execute(
              () -> {
                try {
                  wfEngine_.claim(10, user);
                  Platform.runLater(
                      () -> {
                        claimPopover.hide();
                        claimTasksButton.setDisable(false);
                        refreshContent();
                      });
                } catch (Exception e) {
                  logger.error("Unexpected error claiming tasks", e);
                }
              });
        });

    synchronizeButton.setOnAction(
        (action) -> {
          synchronizeButton.setDisable(true);
          final BusyPopover synchronizePopover =
              BusyPopover.createBusyPopover("Synchronizing tasks...", synchronizeButton);

          Utility.execute(
              () -> {
                try {
                  wfEngine_.synchronizeWithRemote();
                  Platform.runLater(
                      () -> {
                        synchronizePopover.hide();
                        synchronizeButton.setDisable(false);
                        refreshContent();
                      });
                } catch (Exception e) {
                  logger.error("Unexpected error synchronizing tasks", e);
                }
              });
        });
  }