Ejemplo n.º 1
0
  private void deleteDataBean(DataBean bean) {

    // remove from operation history
    for (DataBean source : databeans()) {
      // we must iterate all datas because links cannot be trusted (they might have been removed by
      // user)
      OperationRecord operationRecord = source.getOperationRecord();
      if (operationRecord != null) {
        operationRecord.removeInput(bean);
      }
    }

    // remove links
    for (Link linkType : Link.values()) {
      // Remove outgoing links
      for (DataBean target : bean.getLinkTargets(linkType)) {
        bean.removeLink(linkType, target);
      }
      // Remove incoming links
      for (DataBean source : bean.getLinkSources(linkType)) {
        source.removeLink(linkType, bean);
      }
    }

    // remove bean
    DataFolder folder = bean.getParent();
    if (folder != null) {
      disconnectChild(bean, folder);
    }

    // remove physical file
    bean.delete();
  }
Ejemplo n.º 2
0
  private void linkDataBeans() {
    for (DataBean dataBean : dataBeans.values()) {
      for (LinkType linkType : dataTypes.get(dataBean).getLink()) {
        // if something goes wrong for this link, continue with others
        try {
          String targetID = linkType.getTarget();
          if (targetID != null) {
            DataBean targetBean = dataBeans.get(targetID);
            if (targetBean != null) {
              dataBean.addLink(Link.valueOf(linkType.getType()), targetBean);
            }
          }

        } catch (Exception e) {
          logger.warn("could not add link", e);
          continue;
        }
      }
    }
  }