@Override
  public DataNode createDataNode(DataNodeDescriptor nodeDescriptor) throws Exception {

    DataNode dataNode = new DataNode(nodeDescriptor.getName());

    dataNode.setJdbcEventLogger(jdbcEventLogger);
    dataNode.setRowReaderFactory(rowReaderFactory);
    dataNode.setBatchTranslatorFactory(batchTranslatorFactory);

    dataNode.setDataSourceLocation(nodeDescriptor.getParameters());

    DataSource dataSource = dataSourceFactory.getDataSource(nodeDescriptor);

    dataNode.setDataSourceFactory(nodeDescriptor.getDataSourceFactoryType());
    dataNode.setDataSource(dataSource);

    // schema update strategy
    String schemaUpdateStrategyType = nodeDescriptor.getSchemaUpdateStrategyType();

    if (schemaUpdateStrategyType == null) {
      dataNode.setSchemaUpdateStrategy(defaultSchemaUpdateStrategy);
      dataNode.setSchemaUpdateStrategyName(defaultSchemaUpdateStrategy.getClass().getName());
    } else {
      SchemaUpdateStrategy strategy =
          objectFactory.newInstance(SchemaUpdateStrategy.class, schemaUpdateStrategyType);
      dataNode.setSchemaUpdateStrategyName(schemaUpdateStrategyType);
      dataNode.setSchemaUpdateStrategy(strategy);
    }

    // DbAdapter
    dataNode.setAdapter(adapterFactory.createAdapter(nodeDescriptor, dataSource));

    return dataNode;
  }
  @Override
  public void undo() throws CannotUndoException {
    if (node != null) {
      node.getDataMapNames().remove(map.getName());
      mediator.fireDataNodeEvent(new DataNodeEvent(this, node));
    }

    if (!unlinkedNodes.isEmpty()) {
      for (DataNodeDescriptor unlinkedNode : unlinkedNodes) {
        unlinkedNode.getDataMapNames().add(map.getName());
        mediator.fireDataNodeEvent(new DataNodeEvent(this, unlinkedNode));
      }
    }
  }
Exemplo n.º 3
0
  public void setNodeName(String newName) {
    if (node == null) {
      return;
    }

    // validate...
    if (newName == null) {
      throw new ValidationException("Empty DataNode Name");
    }

    ProjectController parent = (ProjectController) getParent();
    DataNodeDefaults oldPref = parent.getDataNodePreferences();
    DataChannelDescriptor dataChannelDescriptor =
        (DataChannelDescriptor) getApplication().getProject().getRootNode();

    Collection<DataNodeDescriptor> matchingNode = dataChannelDescriptor.getNodeDescriptors();

    Iterator<DataNodeDescriptor> it = matchingNode.iterator();
    while (it.hasNext()) {
      DataNodeDescriptor node = it.next();
      if (node.getName().equals(newName)) {
        // there is an entity with the same name
        throw new ValidationException(
            "There is another DataNode named '" + newName + "'. Use a different name.");
      }
    }

    // passed validation, set value...

    // TODO: fixme....there is a slight chance that domain is different than the one
    // cached node belongs to
    ProjectUtil.setDataNodeName(
        (DataChannelDescriptor) parent.getProject().getRootNode(), node, newName);

    oldPref.copyPreferences(newName);
  }
Exemplo n.º 4
0
 public String getNodeName() {
   return (node != null) ? node.getName() : null;
 }
Exemplo n.º 5
0
 public void setSchemaUpdateStrategy(String schemaUpdateStrategy) {
   if (node != null) {
     node.setSchemaUpdateStrategyType(schemaUpdateStrategy);
   }
 }
Exemplo n.º 6
0
 public String getSchemaUpdateStrategy() {
   return (node != null) ? node.getSchemaUpdateStrategyType() : null;
 }
Exemplo n.º 7
0
 public void setFactoryName(String factoryName) {
   if (node != null) {
     node.setDataSourceFactoryType(factoryName);
     showDataSourceSubview(factoryName);
   }
 }
Exemplo n.º 8
0
 public String getFactoryName() {
   return (node != null) ? node.getDataSourceFactoryType() : null;
 }