コード例 #1
0
  /** Load list of scopes for user selection of top level element for report. */
  private void setupComboScopes() {
    // check if audit was selected by context menu:
    if (this.auditId != null && isContextMenuCall()) {
      scopeCombo.removeAll();
      scopeCombo.add(this.auditName);
      rootElement = auditId;
      scopeCombo.setEnabled(true);
      scopeCombo.select(0);
      scopeCombo.redraw();
      return;
    } else if (this.preSelectedElments != null
        && this.preSelectedElments.size() > 0
        && isContextMenuCall()) {
      scopeCombo.removeAll();
      ArrayList<Integer> auditIDList = new ArrayList<Integer>();
      StringBuilder sb = new StringBuilder();
      for (CnATreeElement elmt : preSelectedElments) {
        sb.append(elmt.getTitle());
        if (preSelectedElments.indexOf(elmt) != preSelectedElments.size() - 1) sb.append(" & ");
        auditIDList.add(elmt.getDbId());
      }
      scopeCombo.add(sb.toString());
      rootElements = auditIDList.toArray(new Integer[auditIDList.size()]);
      scopeCombo.setEnabled(false);
      scopeCombo.select(0);
      scopeCombo.redraw();
      return;
    }

    scopes = new ArrayList<CnATreeElement>();
    scopeTitles = new ArrayList<String>();

    scopes.addAll(loadScopes());
    scopes.addAll(loadITVerbuende());

    Collections.sort(
        scopes,
        new Comparator<CnATreeElement>() {
          @Override
          public int compare(CnATreeElement o1, CnATreeElement o2) {
            return o1.getTitle().compareToIgnoreCase(o2.getTitle());
          }
        });

    for (CnATreeElement elmt : scopes) {
      scopeTitles.add(elmt.getTitle());
      if (LOG.isDebugEnabled()) {
        LOG.debug(
            Messages.GenerateReportDialog_16
                + elmt.getDbId()
                + ": "
                + elmt
                    .getTitle()); //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$
                                  // //$NON-NLS-1$
      }
    }

    String[] titles = scopeTitles.toArray(new String[scopeTitles.size()]);
    scopeCombo.setItems(titles);
  }
コード例 #2
0
  public List<IOOTableRow> getReport(PropertySelection shownColumns) {
    ArrayList<IOOTableRow> rows = new ArrayList<IOOTableRow>();

    AllCategories:
    for (CnATreeElement category : categories) {
      ArrayList<IOOTableRow> categoryRows = new ArrayList<IOOTableRow>();

      AllItems:
      for (CnATreeElement child : getItems(category)) {

        if (child instanceof BausteinUmsetzung) {
          List<String> columns = shownColumns.get(child.getEntity().getEntityType());
          BausteinUmsetzung bst = (BausteinUmsetzung) child;

          categoryRows.add(new PropertiesRow(child, columns, IOOTableRow.ROW_STYLE_SUBHEADER));
          categoryRows.add(
              new SimpleRow(
                  IOOTableRow.ROW_STYLE_SUBHEADER,
                  "Erreichte Siegelstufe: " + Character.toString(bst.getErreichteSiegelStufe())));
          addMassnahmen(shownColumns, categoryRows, bst);
        }
        // else: ignore item
      }

      // only add if header + items present:
      if (categoryRows.size() > 1) {
        rows.add(new SimpleRow(IOOTableRow.ROW_STYLE_HEADER, category.getTitle()));
        rows.addAll(categoryRows);
      }
    }
    return rows;
  }
コード例 #3
0
 private List<UnifyMapping> createMapping(
     Map<String, CnATreeElement> sourceMap, Map<String, CnATreeElement> destinationMap) {
   List<UnifyMapping> mappings = new ArrayList<UnifyMapping>(sourceMap.size());
   for (String title : sourceMap.keySet()) {
     CnATreeElement source = sourceMap.get(title);
     UnifyMapping mapping =
         new UnifyMapping(new UnifyElement(source.getUuid(), source.getTitle()));
     CnATreeElement destination = destinationMap.get(title);
     if (destination != null) {
       mapping.setDestinationElement(
           new UnifyElement(destination.getUuid(), destination.getTitle()));
     }
     mappings.add(mapping);
   }
   return mappings;
 }
コード例 #4
0
 private Map<String, CnATreeElement> loadChildrenTitleMap(
     String uuidParent, Map<String, CnATreeElement> map) {
   RetrieveInfo ri = RetrieveInfo.getChildrenInstance().setChildrenProperties(true);
   ControlGroup source = getDao().findByUuid(uuidParent, ri);
   if (source != null) {
     for (CnATreeElement element : source.getChildren()) {
       if (element instanceof IISO27kGroup) {
         map = loadChildrenTitleMap(element.getUuid(), map);
       } else {
         map.put(getNumberOrTitle(element.getTitle()), element);
       }
     }
   }
   return map;
 }
コード例 #5
0
ファイル: ExportCommand.java プロジェクト: SerNet/verinice
 private CnATreeElement getFromCache(CnATreeElement element) {
   final Element cachedElement = getCache().get(element.getUuid());
   if (cachedElement != null) {
     element = (CnATreeElement) cachedElement.getValue();
     if (getLog().isDebugEnabled()) {
       getLog()
           .debug("Element from cache: " + element.getTitle() + ", UUID: " + element.getUuid());
     }
   } else {
     element = getDao().retrieve(element.getDbId(), RetrieveInfo.getPropertyInstance());
     if (element != null) {
       getCache().put(new Element(element.getUuid(), element));
     }
   }
   return element;
 }
コード例 #6
0
  /**
   * @param shell
   * @param reportScope
   */
  public GenerateReportDialog(Shell shell, Object reportScope) {
    this(shell);
    if (reportScope instanceof Audit) {
      this.useCase = IReportType.USE_CASE_ID_AUDIT_REPORT;
    } else if (reportScope instanceof Organization || reportScope instanceof ITVerbund) {
      this.useCase = IReportType.USE_CASE_ID_GENERAL_REPORT;
    } else {
      this.useCase = IReportType.USE_CASE_ID_ALWAYS_REPORT;
    }
    CnATreeElement cnaElmt = (CnATreeElement) reportScope;

    this.auditId = cnaElmt.getDbId();
    this.auditName = cnaElmt.getTitle();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Setting audit in report dialog: " + auditId); // $NON-NLS-1$
    }
  }
コード例 #7
0
  @Override
  protected Set<CnATreeElement> getObjectsForLeftElement(CnATreeElement assetGroup) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Loading objects for asset group: " + assetGroup.getTitle());
    }
    Set<CnATreeElement> elements = new HashSet<CnATreeElement>();
    elements.add(assetGroup);

    elements.addAll(getGraph().getLinkTargets(assetGroup, Edge.RELATIVES));

    Set<CnATreeElement> scenarios = new HashSet<CnATreeElement>();
    for (CnATreeElement asset : elements) {
      scenarios.addAll(getGraph().getLinkTargets(asset, IncidentScenario.REL_INCSCEN_ASSET));
    }
    Set<CnATreeElement> controls = new HashSet<CnATreeElement>();
    for (CnATreeElement scen : scenarios) {
      controls.addAll(getGraph().getLinkTargets(scen, Control.REL_CONTROL_INCSCEN));
    }
    elements.addAll(scenarios);
    elements.addAll(controls);
    return elements;
  }