use of org.eclipse.vorto.service.mapping.normalized.FunctionblockData in project vorto by eclipse.
the class AbstractDataMapper method mapFunctionBlock.
private FunctionblockData mapFunctionBlock(ModelProperty fbProperty, JXPathContext context) {
FunctionblockData fbData = new FunctionblockData(fbProperty.getName());
FunctionblockModel fbModel = specification.getFunctionBlock(fbProperty.getName());
for (ModelProperty statusProperty : fbModel.getStatusProperties()) {
try {
Object mapped = this.mapProperty(statusProperty, context);
if (mapped != null) {
fbData.withStatusProperty(statusProperty.getName(), mapped);
}
} catch (JXPathNotFoundException | JXPathInvalidAccessException ex) {
if (statusProperty.isMandatory()) {
return null;
}
}
}
for (ModelProperty configProperty : fbModel.getConfigurationProperties()) {
try {
Object mapped = this.mapProperty(configProperty, context);
if (mapped != null) {
fbData.withConfigurationProperty(configProperty.getName(), mapped);
}
} catch (JXPathNotFoundException | JXPathInvalidAccessException ex) {
if (configProperty.isMandatory()) {
return null;
}
}
}
return onlyReturnIfPopulated(fbData);
}
use of org.eclipse.vorto.service.mapping.normalized.FunctionblockData in project vorto by eclipse.
the class AbstractDataMapper method map.
public MappedData map(DataInput input, MappingContext mappingContext) {
JXPathContext context = newContext(input.getValue());
context.setFunctions(converterLibrary);
InfomodelData normalized = new InfomodelData();
final Infomodel deviceInfoModel = specification.getInfoModel();
for (ModelProperty fbProperty : deviceInfoModel.getFunctionblocks()) {
if (mappingContext.isIncluded(fbProperty.getName())) {
FunctionblockData mappedFb = mapFunctionBlock(fbProperty, context);
if (mappedFb != null) {
normalized.withFunctionblock(mappedFb);
}
}
}
return this.doMap(normalized, mappingContext);
}
use of org.eclipse.vorto.service.mapping.normalized.FunctionblockData in project vorto by eclipse.
the class SomePlatformMapper method doMap.
@Override
protected PlatformData doMap(InfomodelData normalized, MappingContext mappingContext) {
PlatformData data = new PlatformData();
State state = new State();
Map<String, Object> status = new HashMap<>();
for (FunctionblockData fbData : normalized.getFunctionblockData()) {
status.put(fbData.getId(), fbData.getStatus());
}
state.setReported(status);
data.setState(state);
return data;
}
use of org.eclipse.vorto.service.mapping.normalized.FunctionblockData in project vorto by eclipse.
the class DittoMapper method doMap.
@Override
protected DittoData doMap(InfomodelData input, MappingContext mappingContext) {
DittoData output = new DittoData();
for (FunctionblockData fbData : input.getFunctionblockData()) {
FeatureBuilder featureBuilder = Feature.newBuilder(fbData.getId());
featureBuilder.withStatus(fbData.getStatus());
output.withFeature(featureBuilder.build());
}
return output;
}
Aggregations