示例#1
0
文件: UnZip.java 项目: JumpMind/metl
  @Override
  public void start() {
    TypedProperties properties = getTypedProperties();

    deleteOnComplete = properties.is(SETTING_DELETE_ON_COMPLETE, deleteOnComplete);

    String sourceResourceId = properties.get(SETTING_SOURCE_RESOURCE);
    IResourceRuntime sourceResource = context.getDeployedResources().get(sourceResourceId);
    if (sourceResource == null) {
      throw new MisconfiguredException("The source resource must be defined");
    } else {
      sourceDir = sourceResource.reference();
    }

    String targetResourceId = properties.get(SETTING_TARGET_RESOURCE);
    IResourceRuntime targetResource = context.getDeployedResources().get(targetResourceId);
    if (targetResource == null) {
      throw new MisconfiguredException("The target resource must be defined");
    } else {
      targetDir = targetResource.reference();
    }

    targetRelativePath = properties.get(SETTING_TARGET_RELATIVE_PATH, "");
    overwrite = properties.is(SETTING_OVERWRITE, overwrite);
    targetSubDir = properties.is(SETTING_TARGET_SUB_DIR, targetSubDir);
    mustExist = properties.is(SETTING_MUST_EXIST, mustExist);
    extractEmptyFiles = properties.is(SETTING_EXTRACT_EMPTY_FILES, extractEmptyFiles);
    encoding = properties.get(SETTING_ENCODING, encoding);
  }
 protected static SqlTemplateSettings createSqlTemplateSettings(TypedProperties properties) {
   SqlTemplateSettings settings = new SqlTemplateSettings();
   settings.setFetchSize(properties.getInt(ParameterConstants.DB_FETCH_SIZE, 1000));
   settings.setQueryTimeout(properties.getInt(ParameterConstants.DB_QUERY_TIMEOUT_SECS, 300));
   settings.setBatchSize(properties.getInt(ParameterConstants.JDBC_EXECUTE_BATCH_SIZE, 100));
   settings.setReadStringsAsBytes(
       properties.is(ParameterConstants.JDBC_READ_STRINGS_AS_BYTES, false));
   return settings;
 }
  public static IDatabasePlatform createDatabasePlatform(
      ApplicationContext springContext,
      TypedProperties properties,
      DataSource dataSource,
      boolean waitOnAvailableDatabase) {
    if (dataSource == null) {
      String jndiName = properties.getProperty(ParameterConstants.DB_JNDI_NAME);
      if (StringUtils.isNotBlank(jndiName)) {
        try {
          log.info("Looking up datasource in jndi.  The jndi name is {}", jndiName);
          JndiObjectFactoryBean jndiFactory = new JndiObjectFactoryBean();
          jndiFactory.setJndiName(jndiName);
          jndiFactory.afterPropertiesSet();
          dataSource = (DataSource) jndiFactory.getObject();

          if (dataSource == null) {
            throw new SymmetricException(
                "Could not locate the configured datasource in jndi.  The jndi name is %s",
                jndiName);
          }
        } catch (IllegalArgumentException e) {
          throw new SymmetricException(
              "Could not locate the configured datasource in jndi.  The jndi name is %s",
              e, jndiName);
        } catch (NamingException e) {
          throw new SymmetricException(
              "Could not locate the configured datasource in jndi.  The jndi name is %s",
              e, jndiName);
        }
      }

      String springBeanName = properties.getProperty(ParameterConstants.DB_SPRING_BEAN_NAME);
      if (isNotBlank(springBeanName) && springContext != null) {
        log.info("Using datasource from spring.  The spring bean name is {}", springBeanName);
        dataSource = (DataSource) springContext.getBean(springBeanName);
      }

      if (dataSource == null) {
        dataSource =
            BasicDataSourceFactory.create(
                properties, SecurityServiceFactory.create(SecurityServiceType.CLIENT, properties));
      }
    }
    if (waitOnAvailableDatabase) {
      waitForAvailableDatabase(dataSource);
    }
    boolean delimitedIdentifierMode =
        properties.is(ParameterConstants.DB_DELIMITED_IDENTIFIER_MODE, true);
    boolean caseSensitive = !properties.is(ParameterConstants.DB_METADATA_IGNORE_CASE, true);
    return JdbcDatabasePlatformFactory.createNewPlatformInstance(
        dataSource, createSqlTemplateSettings(properties), delimitedIdentifierMode, caseSensitive);
  }
示例#4
0
文件: DataDiff.java 项目: digoal/metl
  @Override
  protected void start() {
    error = null;
    TypedProperties properties = getTypedProperties();
    this.sourceStep1Id = properties.get(SOURCE_1);
    if (isBlank(sourceStep1Id)) {
      throw new MisconfiguredException("Please choose a step where the original data comes from");
    }
    this.sourceStep2Id = properties.get(SOURCE_2);
    if (isBlank(sourceStep2Id)) {
      throw new MisconfiguredException("Please choose a step where the data to compare comes from");
    }

    this.inMemoryCompare = properties.is(IN_MEMORY_COMPARE);
    this.rowsPerMessage = properties.getInt(ROWS_PER_MESSAGE);
    Component comp = context.getFlowStep().getComponent();
    comp.setOutputModel(comp.getInputModel());
    Model inputModel = context.getFlowStep().getComponent().getInputModel();
    if (inputModel == null) {
      throw new MisconfiguredException("The input model is not set and it is required");
    }

    entities = new ArrayList<>(inputModel.getModelEntities());
    Collections.sort(
        entities,
        new Comparator<ModelEntity>() {
          @Override
          public int compare(ModelEntity o1, ModelEntity o2) {
            ComponentEntitySetting order1 =
                context
                    .getFlowStep()
                    .getComponent()
                    .getSingleEntitySetting(o1.getId(), DataDiff.ENTITY_ORDER);
            int orderValue1 = order1 != null ? Integer.parseInt(order1.getValue()) : 0;

            ComponentEntitySetting order2 =
                context
                    .getFlowStep()
                    .getComponent()
                    .getSingleEntitySetting(o2.getId(), DataDiff.ENTITY_ORDER);
            int orderValue2 = order2 != null ? Integer.parseInt(order2.getValue()) : 0;

            return new Integer(orderValue1).compareTo(new Integer(orderValue2));
          }
        });
  }
示例#5
0
文件: Http.java 项目: JumpMind/metl
 @Override
 protected void start(TypedProperties properties) {
   streamable =
       new HttpDirectory(
           properties.get(URL),
           properties.get(HTTP_METHOD, HTTP_METHOD_GET),
           properties.get(CONTENT_TYPE),
           properties.getInt(HTTP_TIMEOUT),
           properties.get(SECURITY),
           properties.get(SECURITY_USERNAME),
           properties.get(SECURITY_PASSWORD),
           properties.get(SECURITY_TOKEN_VALUE),
           properties.get(SECURITY_OAUTH10_CONSUMER_KEY),
           properties.get(SECURITY_OAUTH10_CONSUMER_SECRET),
           properties.get(SECURITY_OAUTH10_TOKEN),
           properties.get(SECURITY_OAUTH10_TOKEN_SECRET),
           properties.get(SECURITY_OAUTH10_VERSION),
           properties.get(SECURITY_OAUTH10_SIGNATURE_METHOD),
           properties.get(SECURITY_OAUTH10_REALM));
 }