Exemple #1
0
 /* (non-Javadoc)
  * @see sernet.gs.ui.rcp.main.common.model.CnATreeElement#canContain(java.lang.Object)
  */
 @Override
 public boolean canContain(Object obj) {
   boolean canContain = false;
   if (obj instanceof CnATreeElement) {
     CnATreeElement element = (CnATreeElement) obj;
     canContain =
         Arrays.asList(getChildTypes()).contains(element.getTypeId())
             || this.getTypeId().equals(element.getTypeId());
   }
   return canContain;
 }
Exemple #2
0
 /** @param exportThread */
 private void getValuesFromThread(final ExportThread exportThread) {
   linkSet.addAll(exportThread.getLinkSet());
   attachmentSet.addAll(exportThread.getAttachmentSet());
   exportedEntityTypes.addAll(exportThread.getExportedEntityTypes());
   exportedTypes.addAll(exportThread.getExportedTypes());
   changedElements.addAll(exportThread.getChangedElementList());
   final CnATreeElement element = getElementFromThread(exportThread);
   if (element != null && FinishedRiskAnalysis.TYPE_ID.equals(element.getTypeId())) {
     riskAnalysisIdSet.add(element.getDbId());
   }
 }
Exemple #3
0
  private void exportChildren(final ExportTransaction transaction) throws CommandException {
    final int timeOutFactor = 40;
    final CnATreeElement element = transaction.getElement();
    final Set<CnATreeElement> children = element.getChildren();
    if (FinishedRiskAnalysis.TYPE_ID.equals(element.getTypeId())) {
      children.addAll(getRiskAnalysisOrphanElements(element));
    }

    final List<ExportTransaction> transactionList = new ArrayList<ExportTransaction>();

    taskExecutor = Executors.newFixedThreadPool(getMaxNumberOfThreads());
    if (!children.isEmpty()) {
      for (final CnATreeElement child : children) {
        final ExportTransaction childTransaction = new ExportTransaction(child);
        transactionList.add(childTransaction);
        final ExportThread thread = new ExportThread(childTransaction);
        configureThread(thread);

        // Multi thread:
        thread.addListener(
            new IThreadCompleteListener() {
              @Override
              public void notifyOfThreadComplete(final Thread thread) {
                final ExportThread exportThread = (ExportThread) thread;
                synchronized (LOCK) {
                  if (exportThread.getSyncObject() != null) {
                    transaction.getTarget().getChildren().add(exportThread.getSyncObject());
                  }
                  getValuesFromThread(exportThread);
                }
              }
            });
        taskExecutor.execute(thread);
      }
    }

    awaitTermination(transactionList.size() * timeOutFactor);

    if (getLog().isDebugEnabled() && transactionList.size() > 0) {
      getLog().debug(transactionList.size() + " export threads finished.");
    }

    for (final ExportTransaction childTransaction : transactionList) {
      if (checkElement(childTransaction.getElement())) {
        exportChildren(childTransaction);
      }
    }
  }
Exemple #4
0
 private boolean checkElement(final CnATreeElement element) {
   return (getEntityTypesBlackList() == null
           || getEntityTypesBlackList().get(element.getTypeId()) == null)
       && (getEntityClassBlackList() == null
           || getEntityClassBlackList().get(element.getClass()) == null);
 }