Ejemplo n.º 1
0
    @Override
    public List<AbstractEvent> map(
        Config config,
        String configRoot,
        AbstractEvent sourceEvent,
        Set<Integer> destinationGroupSet,
        int totalDestinationGroups) {
      String namespacePath = MapperHelper.getNamespacePath(configRoot, sourceEvent);
      ConfigValue configValue = mapperConfig.getConfigValue(config, namespacePath);

      Set<String> exclusionSet = getExclusionSet(configValue);
      MapAllValues mapAll = getMapAll(configValue);

      if (mapAll == MapAllValues.FALSE || exclusionSet.contains(sourceEvent.getEntityName())) {
        return new ArrayList<AbstractEvent>();
      }

      AbstractEvent destinationEvent =
          destinationEventFactory.createEvent(
              sourceEvent.getFieldMapPair(),
              sourceEvent.getPrimaryKeySet(),
              sourceEvent.getEntityName(),
              sourceEvent.getNamespaceName(),
              sourceEvent.getEventType());

      return Arrays.asList(destinationEvent);
    }
Ejemplo n.º 2
0
    @Override
    public List<AbstractEvent> map(
        Config config,
        String configRoot,
        AbstractEvent sourceEvent,
        Set<Integer> destinationGroupSet,
        int totalDestinationGroups) {
      List<AbstractEvent> destinationEventList = new ArrayList<AbstractEvent>();

      String entityPath = MapperHelper.getEntityPath(configRoot, sourceEvent);

      ConfigList configList = mapperConfig.getConfigList(config, entityPath);

      for (ConfigValue destinationConfig : configList) {
        String destinationNamespace = sourceEvent.getNamespaceName();
        if (mapperConfig.checkIfKeyExists(
            MapperConstants.DESTINATION_NAMESPACE_FIELD_NAME, destinationConfig)) {
          destinationNamespace =
              mapperConfig.getValueForKeyAsString(
                  MapperConstants.DESTINATION_NAMESPACE_FIELD_NAME, destinationConfig);
        }

        String destinationEntity = sourceEvent.getEntityName();

        if (mapperConfig.checkIfKeyExists(
            MapperConstants.DESTINATION_ENTITY_FIELD_NAME, destinationConfig)) {
          destinationEntity =
              mapperConfig.getValueForKeyAsString(
                  MapperConstants.DESTINATION_ENTITY_FIELD_NAME, destinationConfig);
        }

        int groupNo =
            getEventGroupNo(
                totalDestinationGroups, destinationConfig, destinationNamespace, destinationEntity);

        if (!destinationGroupSet.contains(groupNo)) {
          continue;
        }

        MapAllValues mapAll = getMapAll(destinationConfig);
        Set<String> exclusionSet = getExclusionSet(destinationConfig);
        Map<String, Object> destinationEventColumnMap =
            getColumnMap(sourceEvent, destinationConfig, mapAll, exclusionSet);
        Set<String> primaryKeySet = getPrimaryKeySet(sourceEvent, destinationConfig);

        AbstractEvent destinationEvent =
            destinationEventFactory.createEvent(
                destinationEventColumnMap,
                primaryKeySet,
                destinationEntity,
                destinationNamespace,
                sourceEvent.getEventType());

        destinationEventList.add(destinationEvent);
      }
      return destinationEventList;
    }
Ejemplo n.º 3
0
  /**
   * Gets the map of column mapping from the {@link ConfigValue} if exists, otherwise, returns the
   * primary keys of the passed source event, which varies as per the values of mapAll and
   * exclusionList defined in the {@code ConfigValue}.
   *
   * @param sourceEvent
   * @param destinationConfig
   * @param mapAll
   * @param exclusionSet
   * @return Source to Destination Event Column Mapping
   */
  protected Map<String, Object> getColumnMap(
      AbstractEvent sourceEvent,
      ConfigValue destinationConfig,
      MapAllValues mapAll,
      Set<String> exclusionSet) {
    Map<String, Object> destinationEventColumnMap = null;
    if (mapperConfig.checkIfKeyExists(
        MapperConstants.DESTINATION_COLUMN_MAPPING, destinationConfig)) {
      ConfigObject columnMappingConfigObject =
          mapperConfig.getValueForKeyAsConfigValue(
              MapperConstants.DESTINATION_COLUMN_MAPPING, destinationConfig, ConfigObject.class);

      destinationEventColumnMap =
          MapperHelper.getEventColumnMapping(
              sourceEvent.getFieldMapPair(), columnMappingConfigObject, mapAll, exclusionSet);
    } else {
      destinationEventColumnMap =
          MapperHelper.getEventColumnMapping(
              sourceEvent.getFieldMapPair(), null, mapAll, exclusionSet);
    }
    return destinationEventColumnMap;
  }