use of io.atlasmap.v2.StringList in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateAtlasMapping.
protected AtlasMapping generateAtlasMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("junit");
generateXmlDataSource(atlasMapping);
generateLookupTables(atlasMapping);
Actions actions = generateActions();
StringList stringList = new StringList();
stringList.getString().add("XmlAccessorType");
stringList.getString().add("XmlType");
Restrictions restrictions = new Restrictions();
Restriction restriction = new Restriction();
restriction.setType(RestrictionType.LENGTH);
restriction.setValue("100");
restrictions.getRestriction().add(restriction);
Mapping mapping = AtlasModelFactory.createMapping(MappingType.MAP);
XmlField inputField = generateXmlField(actions, stringList, restrictions);
mapping.getInputField().add(inputField);
XmlField outputField = generateXmlField(actions, stringList, restrictions);
mapping.getOutputField().add(outputField);
mapping.setMappingType(MappingType.MAP);
mapping.setDelimiterString(",");
mapping.setAlias("MapPropertyFieldAlias");
mapping.setDelimiter(",");
mapping.setDescription("description");
mapping.setId("id");
mapping.setLookupTableName("lookupTableName");
mapping.setStrategy("strategy");
mapping.setStrategyClassName("strategyClassName");
atlasMapping.getMappings().getMapping().add(mapping);
generateProperties(atlasMapping);
return atlasMapping;
}
use of io.atlasmap.v2.StringList in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateParameterizedTypes.
private StringList generateParameterizedTypes() {
StringList parameterizedTypes = new StringList();
parameterizedTypes.getString().add("String");
parameterizedTypes.getString().add("Integer");
return parameterizedTypes;
}
use of io.atlasmap.v2.StringList in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateClassInspectionRequest.
public ClassInspectionRequest generateClassInspectionRequest() {
ClassInspectionRequest classInspectionRequest = new ClassInspectionRequest();
classInspectionRequest.setClasspath("/Users/mattrpav/.m2/repository/org/twitter4j/twitter4j-core/4.0.5/twitter4j-core-4.0.5.jar");
classInspectionRequest.setClassName("twitter4j.StatusJSONImpl");
classInspectionRequest.setFieldNameBlacklist(new StringList());
classInspectionRequest.getFieldNameBlacklist().getString().add("createdAt");
return classInspectionRequest;
}
use of io.atlasmap.v2.StringList in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateSeparateAtlasMapping.
protected AtlasMapping generateSeparateAtlasMapping() {
Actions actions = generateActions();
StringList annotations = generateAnnotations();
ModifierList modifierList = generateModifierList();
StringList parameterizedTypes = generateParameterizedTypes();
JavaField inputJavaField = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
JavaField outputJavaFieldA = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
JavaField outputJavaFieldB = generateJavaField(actions, annotations, modifierList, parameterizedTypes);
Mapping fm = (Mapping) AtlasModelFactory.createMapping(MappingType.SEPARATE);
fm.getInputField().add(inputJavaField);
fm.getOutputField().add(outputJavaFieldA);
fm.getOutputField().add(outputJavaFieldB);
populateMapping(fm, MappingType.SEPARATE, "MapPropertyFieldAlias", ",", ",");
populateMappingString(fm, "description", "id", "lookupTableName", "strategy", "strategyClassName");
AtlasMapping mapping = generateAtlasMapping();
mapping.getMappings().getMapping().clear();
mapping.getMappings().getMapping().add(fm);
return mapping;
}
use of io.atlasmap.v2.StringList in project atlasmap by atlasmap.
the class ClassInspectionService method inspectField.
private JavaField inspectField(ClassLoader classLoader, Field f, Set<String> cachedClasses, String pathPrefix) {
JavaField s = AtlasJavaModelFactory.createJavaField();
Class<?> clazz = f.getType();
s.setName(f.getName());
if (pathPrefix != null && pathPrefix.length() > 0) {
s.setPath(pathPrefix + AtlasPath.PATH_SEPARATOR + f.getName());
} else {
s.setPath(f.getName());
}
if (isMapList(clazz.getCanonicalName())) {
s.setCollectionType(CollectionType.MAP);
}
if (clazz.isArray()) {
s.setCollectionType(CollectionType.ARRAY);
s.setArrayDimensions(detectArrayDimensions(clazz));
clazz = detectArrayClass(clazz);
} else if (isFieldList(clazz.getCanonicalName())) {
s.setCollectionType(CollectionType.LIST);
s.setCollectionClassName(clazz.getCanonicalName());
try {
clazz = detectListClass(classLoader, f);
if (clazz == null) {
s.setStatus(FieldStatus.ERROR);
return s;
}
} catch (ClassCastException | ClassNotFoundException cce) {
LOG.debug("Error detecting inner listClass: " + cce.getMessage() + " for field: " + f.getName(), cce);
s.setStatus(FieldStatus.ERROR);
return s;
}
}
s.setFieldType(getConversionService().fieldTypeFromClass(clazz));
if (getConversionService().isPrimitive(clazz) || getConversionService().isBoxedPrimitive(clazz)) {
s.setPrimitive(true);
s.setStatus(FieldStatus.SUPPORTED);
} else if (s.getFieldType() != FieldType.COMPLEX) {
s.setPrimitive(false);
s.setStatus(FieldStatus.SUPPORTED);
} else {
s.setPrimitive(false);
Class<?> complexClazz = null;
JavaClass tmpField = convertJavaFieldToJavaClass(s);
s = tmpField;
if (clazz.getCanonicalName() == null) {
s.setStatus(FieldStatus.UNSUPPORTED);
} else if (!cachedClasses.contains(clazz.getCanonicalName())) {
try {
complexClazz = classLoader.loadClass(clazz.getCanonicalName());
cachedClasses.add(clazz.getCanonicalName());
inspectClass(classLoader, complexClazz, tmpField, cachedClasses, s.getPath());
if (tmpField.getStatus() == null) {
s.setStatus(FieldStatus.SUPPORTED);
}
} catch (ClassNotFoundException cnfe) {
s.setStatus(FieldStatus.NOT_FOUND);
}
} else {
s.setStatus(FieldStatus.CACHED);
}
}
s.setClassName(clazz.getCanonicalName());
s.setSynthetic(f.isSynthetic());
Annotation[] annotations = f.getAnnotations();
if (annotations != null) {
for (Annotation a : annotations) {
if (s.getAnnotations() == null) {
s.setAnnotations(new StringList());
}
s.getAnnotations().getString().add(a.annotationType().getCanonicalName());
}
}
if (s.getModifiers() == null) {
s.setModifiers(new ModifierList());
}
s.getModifiers().getModifier().addAll(detectModifiers(f.getModifiers()));
List<String> pTypes = detectParameterizedTypes(f, false);
if (pTypes != null) {
if (s.getParameterizedTypes() == null) {
s.setParameterizedTypes(new StringList());
}
s.getParameterizedTypes().getString().addAll(pTypes);
}
populateGetterSetter(clazz, f, s);
return s;
}
Aggregations