io.atlasmap.core.PropertyModule Maven / Gradle / Ivy
/**
* Copyright (C) 2017 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.atlasmap.core;
import java.util.Arrays;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.atlasmap.api.AtlasConversionService;
import io.atlasmap.api.AtlasException;
import io.atlasmap.api.AtlasFieldActionService;
import io.atlasmap.spi.AtlasInternalSession;
import io.atlasmap.spi.AtlasModule;
import io.atlasmap.spi.AtlasModuleMode;
import io.atlasmap.spi.AtlasPropertyStrategy;
import io.atlasmap.v2.Field;
import io.atlasmap.v2.PropertyField;
public class PropertyModule implements AtlasModule {
private static final Logger LOG = LoggerFactory.getLogger(PropertyModule.class);
private AtlasPropertyStrategy propertyStrategy;
private AtlasConversionService conversionService;
private AtlasFieldActionService fieldActionService;
public PropertyModule(AtlasPropertyStrategy propertyStrategy) {
this.propertyStrategy = propertyStrategy;
}
@Override
public void init() {
// no-op
}
@Override
public void destroy() {
// no-op
}
@Override
public void processPreValidation(AtlasInternalSession session) throws AtlasException {
// TODO
}
@Override
public void processPreSourceExecution(AtlasInternalSession session) throws AtlasException {
// no-op
}
@Override
public void processSourceFieldMapping(AtlasInternalSession session) throws AtlasException {
Field sourceField = session.head().getSourceField();
if (sourceField instanceof PropertyField) {
propertyStrategy.processPropertyField(session.getMapping(), (PropertyField) sourceField,
session.getProperties());
}
if (LOG.isDebugEnabled()) {
LOG.debug("Processed input propertyField sPath=" + sourceField.getPath() + " sV="
+ sourceField.getValue() + " sT=" + sourceField.getFieldType() + " docId: " + sourceField.getDocId());
}
}
@Override
public void processPostSourceExecution(AtlasInternalSession session) throws AtlasException {
// no-op
}
@Override
public void processPreTargetExecution(AtlasInternalSession session) throws AtlasException {
throw new UnsupportedOperationException("PropertyField cannot be placed as a target field");
}
@Override
public void processTargetFieldMapping(AtlasInternalSession session) throws AtlasException {
throw new UnsupportedOperationException("PropertyField cannot be placed as a target field");
}
@Override
public void processPostTargetExecution(AtlasInternalSession session) throws AtlasException {
throw new UnsupportedOperationException("PropertyField cannot be placed as a target field");
}
@Override
public void processPostValidation(AtlasInternalSession session) throws AtlasException {
// no-op
}
@Override
public AtlasModuleMode getMode() {
return AtlasModuleMode.SOURCE;
}
@Override
public void setMode(AtlasModuleMode atlasModuleMode) {
// no-op
}
@Override
public AtlasConversionService getConversionService() {
return this.conversionService;
}
@Override
public void setConversionService(AtlasConversionService atlasConversionService) {
this.conversionService = atlasConversionService;
}
@Override
public List listSupportedModes() {
return Arrays.asList(new AtlasModuleMode[] { AtlasModuleMode.SOURCE });
}
@Override
public String getDocId() {
return null;
}
@Override
public void setDocId(String docId) {
// no-op
}
@Override
public String getUri() {
return null;
}
@Override
public void setUri(String uri) {
// no-op
}
@Override
public Boolean isStatisticsSupported() {
return false;
}
@Override
public Boolean isStatisticsEnabled() {
return false;
}
@Override
public Boolean isSupportedField(Field field) {
return field instanceof PropertyField;
}
@Override
public Field cloneField(Field field) throws AtlasException {
return null;
}
@Override
public int getCollectionSize(AtlasInternalSession session, Field field) throws AtlasException {
return 0;
}
@Override
public AtlasFieldActionService getFieldActionService() {
return this.fieldActionService;
}
@Override
public void setFieldActionService(AtlasFieldActionService atlasFieldActionService) {
this.fieldActionService = atlasFieldActionService;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy