use of eu.esdihumboldt.cst.ConceptualSchemaTransformer in project hale by halestudio.
the class ReprojectGeometryTest method transformData.
@Override
protected List<Instance> transformData(TransformationExample example) throws Exception {
ConceptualSchemaTransformer transformer = new ConceptualSchemaTransformer();
DefaultInstanceSink sink = new DefaultInstanceSink();
final Map<Class<?>, Object> customServices = new HashMap<>();
customServices.put(FunctionService.class, new AlignmentFunctionService(example.getAlignment()));
customServices.put(TransformationFunctionService.class, new AlignmentTransformationFunctionService(example.getAlignment()));
final ServiceProvider serviceProvider = new ServiceProvider() {
private final ServiceProvider projectScope = new ServiceManager(ServiceManager.SCOPE_PROJECT);
@SuppressWarnings("unchecked")
@Override
public <T> T getService(Class<T> serviceInterface) {
if (customServices.containsKey(serviceInterface)) {
return (T) customServices.get(serviceInterface);
}
// FIXME global scope not supported yet
return projectScope.getService(serviceInterface);
}
};
transformer.transform(example.getAlignment(), example.getSourceInstances(), sink, serviceProvider, new NullProgressIndicator());
return sink.getInstances();
}
use of eu.esdihumboldt.cst.ConceptualSchemaTransformer in project hale by halestudio.
the class ConceptualSchemaTransformerTest method transformData.
@Override
protected List<Instance> transformData(TransformationExample example) throws Exception {
ConceptualSchemaTransformer transformer = new ConceptualSchemaTransformer();
ThreadSafeInstanceSink<DefaultInstanceSink> sink = new ThreadSafeInstanceSink<>(new DefaultInstanceSink());
final Map<Class<?>, Object> customServices = new HashMap<>();
customServices.put(FunctionService.class, new AlignmentFunctionService(example.getAlignment()));
customServices.put(TransformationFunctionService.class, new AlignmentTransformationFunctionService(example.getAlignment()));
InstanceIndexServiceImpl indexService = new InstanceIndexServiceImpl();
customServices.put(InstanceIndexService.class, indexService);
final ServiceProvider serviceProvider = new ServiceProvider() {
private final ServiceProvider projectScope = new ServiceManager(ServiceManager.SCOPE_PROJECT);
@SuppressWarnings("unchecked")
@Override
public <T> T getService(Class<T> serviceInterface) {
if (customServices.containsKey(serviceInterface)) {
return (T) customServices.get(serviceInterface);
}
// FIXME global scope not supported yet
return projectScope.getService(serviceInterface);
}
};
indexService.addPropertyMappings(example.getAlignment().getActiveTypeCells(), serviceProvider);
InstanceCollection source = example.getSourceInstances();
try (ResourceIterator<Instance> it = source.iterator()) {
while (it.hasNext()) {
indexService.add(it.next(), source);
}
}
transformer.transform(example.getAlignment(), source, sink, serviceProvider, new NullProgressIndicator());
return sink.getDecoratee().getInstances();
}
Aggregations