Ejemplo n.º 1
0
  public WorkingSetSelectorPopup(RuleModeller m, RuleAsset a) {
    this.modeller = m;
    this.asset = a;

    pop = new FormStylePopup();
    Constants constants = ((Constants) GWT.create(Constants.class));
    pop.setTitle(constants.SelectWorkingSets());
    Grid g = buildDoubleList(null);

    RepositoryServiceFactory.getAssetService()
        .listAssets(
            asset.getMetaData().getPackageUUID(),
            new String[] {AssetFormats.WORKING_SET},
            0,
            -1,
            "workingsetList",
            new GenericCallback<TableDataResult>() {

              public void onSuccess(TableDataResult result) {

                for (int i = 0; i < result.data.length; i++) {
                  if (WorkingSetManager.getInstance()
                      .isWorkingSetActive(
                          asset.getMetaData().getPackageName(), result.data[i].id)) {
                    selectedFacts.addItem(result.data[i].getDisplayName(), result.data[i].id);
                  } else {
                    availableFacts.addItem(result.data[i].getDisplayName(), result.data[i].id);
                  }
                }
              }
            });

    Button save = new Button(constants.SaveAndClose());
    save.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            String[] wsUUIDs = new String[selectedFacts.getItemCount()];
            for (int i = 0; i < selectedFacts.getItemCount(); i++) {
              wsUUIDs[i] = selectedFacts.getValue(i);
            }

            WorkingSetManager.getInstance()
                .applyWorkingSets(
                    asset.getMetaData().getPackageName(),
                    wsUUIDs,
                    new Command() {
                      public void execute() {
                        LoadingPopup.close();
                        pop.hide();
                        modeller.refreshWidget();
                        modeller.verifyRule(null, true);
                      }
                    });
          }
        });

    pop.addRow(g);
    pop.addRow(save);
  }
  private AnalysisReport performAssetVerification(
      RuleAsset asset, boolean useVerifierDefaultConfig, Set<String> activeWorkingSets)
      throws SerializationException {
    long startTime = System.currentTimeMillis();

    if (Contexts.isSessionContextActive()) {
      Identity.instance()
          .checkPermission(
              new PackageNameType(asset.getMetaData().getPackageName()),
              RoleType.PACKAGE_DEVELOPER.getName());
    }

    PackageItem packageItem =
        getAssetService().getRulesRepository().loadPackage(asset.getMetaData().getPackageName());

    List<String> constraintRules = applyWorkingSets(activeWorkingSets);

    Verifier verifierToBeUsed = null;
    if (useVerifierDefaultConfig) {
      verifierToBeUsed = defaultVerifier;
    } else {
      verifierToBeUsed = getWorkingSetVerifier(constraintRules);
    }

    log.debug("constraints rules: " + constraintRules);

    try {
      VerifierRunner runner = new VerifierRunner(verifierToBeUsed);
      AnalysisReport report = runner.verify(packageItem, chooseScopesAgendaFilterFor(asset));

      verifierToBeUsed.flushKnowledgeSession();

      log.debug("Asset verification took: " + (System.currentTimeMillis() - startTime));

      return report;

    } catch (Throwable t) {
      throw new SerializationException(t.getMessage());
    }
  }
 private boolean isAssetDecisionTable(RuleAsset asset) {
   return AssetFormats.DECISION_TABLE_GUIDED.equals(asset.getMetaData().getFormat())
       || AssetFormats.DECISION_SPREADSHEET_XLS.equals(asset.getMetaData().getFormat());
 }