use of eu.esdihumboldt.hale.common.schema.model.PropertyDefinition in project hale by halestudio.
the class AbstractAlignmentMappingExport method addCellData.
// get the information of the cell and add them to the map
private void addCellData(Cell cell) {
Map<CellType, CellInformation> cellInfos = new HashMap<CellType, CellInformation>();
// create all entries
List<CellType> cellTypes = getCellTypes();
for (int i = 0; i < cellTypes.size(); i++) {
cellInfos.put(cellTypes.get(i), new CellInformation());
}
cellInfos.get(CellType.ID).addText(cell.getId(), 0);
if (cell.getSource() != null) {
// save the hierarchy of the properties
// all entries (in the same CellInfo) with the same hierarchy level
// have to be shown on the same height
int position = 0;
for (Entity entity : cell.getSource().values()) {
// column source type
cellInfos.get(CellType.SOURCE_TYPE).addText(entity.getDefinition().getType().getName().getLocalPart(), position);
if (includeNamespaces)
// column source type namespace
cellInfos.get(CellType.SOURCE_TYPE_NAMESPACE).addText(entity.getDefinition().getType().getName().getNamespaceURI(), position);
// column source type conditions
Filter entityFilter;
if ((entityFilter = entity.getDefinition().getFilter()) != null) {
cellInfos.get(CellType.SOURCE_TYPE_CONDITIONS).addText(FilterDefinitionManager.getInstance().asString(entityFilter), position);
entity.getDefinition().getType().getName().getLocalPart();
}
for (ChildContext childContext : entity.getDefinition().getPropertyPath()) {
PropertyDefinition child = childContext.getChild().asProperty();
if (child != null) {
// column source properties
cellInfos.get(CellType.SOURCE_PROPERTIES).addText(child.getName().getLocalPart(), position);
if (includeNamespaces)
// column source properties namespace
cellInfos.get(CellType.SOURCE_PROPERTIES_NAMESPACE).addText(child.getName().getNamespaceURI(), position);
Filter contextFilter;
if (childContext.getCondition() != null) {
contextFilter = childContext.getCondition().getFilter();
// column source property conditions
cellInfos.get(CellType.SOURCE_PROPERTY_CONDITIONS).addText(FilterDefinitionManager.getInstance().asString(contextFilter), position);
}
// add dummy to adapt position of source type and source
// type conditions
cellInfos.get(CellType.SOURCE_TYPE).addText("", position);
cellInfos.get(CellType.SOURCE_TYPE_CONDITIONS).addText("", position);
position++;
}
}
// next entries must have higher position
position++;
}
}
if (cell.getTarget() != null) {
int position = 0;
for (Entity entity : cell.getTarget().values()) {
// column target type
cellInfos.get(CellType.TARGET_TYPE).addText(entity.getDefinition().getType().getDisplayName(), position);
if (includeNamespaces)
// column target type namespace
cellInfos.get(CellType.TARGET_TYPE_NAMESPACE).addText(entity.getDefinition().getType().getName().getNamespaceURI(), position);
for (ChildContext childContext : entity.getDefinition().getPropertyPath()) {
PropertyDefinition child = childContext.getChild().asProperty();
if (child != null) {
// column target properties
cellInfos.get(CellType.TARGET_PROPERTIES).addText(child.getName().getLocalPart(), position);
if (includeNamespaces)
// column target properties namespace
cellInfos.get(CellType.TARGET_PROPERTIES_NAMESPACE).addText(child.getName().getNamespaceURI(), position);
// add dummy to adapt position of target type
cellInfos.get(CellType.TARGET_TYPE).addText("", position);
position++;
}
}
position++;
}
}
FunctionDefinition<?> function = FunctionUtil.getFunction(cell.getTransformationIdentifier(), getServiceProvider());
if (function != null) {
// column relation name
cellInfos.get(CellType.RELATION_NAME).addText(function.getDisplayName(), 0);
// column cell explanation
CellExplanation cellExpl = function.getExplanation();
if (cellExpl != null) {
cellInfos.get(CellType.CELL_EXPLANATION).addText(function.getExplanation().getExplanation(cell, null), 0);
}
}
// column cell notes
List<String> docs = cell.getDocumentation().get(null);
if (!docs.isEmpty()) {
String notes = docs.get(0);
if (notes != null && !notes.isEmpty()) {
cellInfos.get(CellType.CELL_NOTES).addText(notes, 0);
}
}
// cell priority
cellInfos.get(CellType.PRIORITY).addText(cell.getPriority().value(), 0);
// base cell
if (cell.isBaseCell()) {
cellInfos.get(CellType.BASE_CELL).addText("yes", 0);
} else {
cellInfos.get(CellType.BASE_CELL).addText("no", 0);
}
// column transformation/disabled
if (transformationAndDisabledMode) {
if (AlignmentUtil.isTypeCell(cell)) {
currentTypeCell = cell;
cellInfos.get(CellType.TRANSFORMATION_AND_DISABLED).addText(cell.getTransformationMode().displayName(), 0);
} else {
Set<String> disabledCells = cell.getDisabledFor();
if (disabledCells.contains(currentTypeCell.getId())) {
for (String disCell : disabledCells) {
cellInfos.get(CellType.TRANSFORMATION_AND_DISABLED).addText(disCell, 0);
}
}
}
}
// add the row to the map
allRelations.add(cellInfos);
}
use of eu.esdihumboldt.hale.common.schema.model.PropertyDefinition in project hale by halestudio.
the class XPathFilterField method selectVariable.
/**
* @see eu.esdihumboldt.hale.ui.filter.TypeFilterField#selectVariable()
*/
@Override
protected String selectVariable() {
XPathPropertyDefinitionDialog dialog = new XPathPropertyDefinitionDialog(Display.getCurrent().getActiveShell(), entity, "Insert attribute name", null);
if (dialog.open() == XPathPropertyDefinitionDialog.OK && dialog.getObject() != null) {
EntityDefinition entityDef = dialog.getObject();
StringBuilder var = new StringBuilder();
for (int i = 0; i < dialog.getParentCount(); i++) var.append("../");
// skip the first path element if we didn't start at top level
int start = dialog.atTopLevel() ? 0 : 1;
// if the element itself was selected simply use a single dot
if (dialog.getParentCount() == 0 && entityDef.getPropertyPath().size() == start)
var.append(".");
boolean first = true;
for (int i = start; i < entityDef.getPropertyPath().size(); i++) {
PropertyDefinition propDef = entityDef.getPropertyPath().get(i).getChild().asProperty();
if (propDef != null) {
if (first)
first = false;
else
var.append("/");
if (propDef.getConstraint(XmlAttributeFlag.class).isEnabled())
var.append('@');
QName name = entityDef.getPropertyPath().get(i).getChild().getName();
if (!XMLConstants.NULL_NS_URI.equals(name.getNamespaceURI()))
var.append("\"").append(name.getNamespaceURI()).append("\":");
var.append(name.getLocalPart());
}
}
return var.toString();
} else
return null;
}
use of eu.esdihumboldt.hale.common.schema.model.PropertyDefinition in project hale by halestudio.
the class GeographicalNameTarget method accept.
/**
* @see EntityCondition#accept(Entity)
*/
@Override
public boolean accept(Property entity) {
TypeDefinition propertyType = entity.getDefinition().getDefinition().getPropertyType();
PropertyDefinition nameProperty = Util.getChild("GeographicalName", propertyType);
if (nameProperty != null) {
propertyType = nameProperty.getPropertyType();
return propertyType.getName().getLocalPart().equals("GeographicalNameType") && propertyType.getName().getNamespaceURI().startsWith("urn:x-inspire:specification:gmlas:GeographicalNames");
}
return false;
}
use of eu.esdihumboldt.hale.common.schema.model.PropertyDefinition in project hale by halestudio.
the class Identifier method evaluate.
@Override
protected Object evaluate(String transformationIdentifier, TransformationEngine engine, ListMultimap<String, PropertyValue> variables, String resultName, PropertyEntityDefinition resultProperty, Map<String, String> executionParameters, TransformationLog log) throws TransformationException, NoResultException {
// get input
PropertyValue input = variables.get(null).get(0);
// source value as string (will be written into localid)
String source = input.getValueAs(String.class);
// get all values for the parameters set by the parameter page
String countryName = getParameterChecked(COUNTRY_PARAMETER_NAME).as(String.class);
String providerName = getParameterChecked(DATA_PROVIDER_PARAMETER_NAME).as(String.class);
String productName = getParameterChecked(PRODUCT_PARAMETER_NAME).as(String.class);
String version = getParameterChecked(VERSION).as(String.class);
String versionNilReason = getParameterChecked(VERSION_NIL_REASON).as(String.class);
// definition of the target property (inspireId in this case)
TypeDefinition targetType = resultProperty.getDefinition().getPropertyType();
// instance that can be changed (add property/instance as child)
DefaultInstance inspireInstance = new DefaultInstance(targetType, null);
// search for the child named "Identifier"
PropertyDefinition inspireChildPropDef = Util.getChild("Identifier", targetType);
// get type definition to create the "Identifier" instance
TypeDefinition identType = inspireChildPropDef.getPropertyType();
DefaultInstance identInstance = new DefaultInstance(identType, null);
PropertyDefinition identChildLocal = Util.getChild("localId", identType);
PropertyDefinition identChildNamespace = Util.getChild("namespace", identType);
PropertyDefinition identChildVersion = Util.getChild("versionId", identType);
TypeDefinition versionType = identChildVersion.getPropertyType();
// 1.)
// add the "localId" and "namespace" properties to the identifier
// instance
identInstance.addProperty(identChildLocal.getName(), source);
identInstance.addProperty(identChildNamespace.getName(), getNamespace(countryName, providerName, productName, getTargetType()));
DefaultInstance versionInstance = null;
// add the "nilReason" property to the version instance
if (version == null || version.isEmpty()) {
if (!versionNilReason.isEmpty()) {
versionInstance = new DefaultInstance(versionType, null);
PropertyDefinition versionIdChildVersion = Util.getChild("nilReason", versionType);
versionInstance.addProperty(versionIdChildVersion.getName(), versionNilReason);
}
} else {
versionInstance = new DefaultInstance(versionType, null);
versionInstance.setValue(version);
}
// add the "versionId" instance to the identifier instance
if (versionInstance != null) {
identInstance.addProperty(identChildVersion.getName(), versionInstance);
}
// 4.)
// add the "identifier" instance to the inspireId instance
inspireInstance.addProperty(inspireChildPropDef.getName(), identInstance);
return inspireInstance;
}
use of eu.esdihumboldt.hale.common.schema.model.PropertyDefinition in project hale by halestudio.
the class PropertyOrChildrenTypeCondition method accept.
private boolean accept(EntityDefinition entityDef, Set<TypeDefinition> tested) {
Definition<?> def = entityDef.getDefinition();
if (def instanceof PropertyDefinition) {
// test the property definition and its property type
TypeDefinition type = ((PropertyDefinition) def).getPropertyType();
if (tested.contains(type)) {
// we already tested that type
return false;
}
if (accept(type, entityDef.getSchemaSpace())) {
return true;
}
tested.add(type);
}
// test the children
for (ChildDefinition<?> child : DefinitionUtil.getAllChildren(DefinitionUtil.getDefinitionGroup(def))) {
EntityDefinition childDef = AlignmentUtil.getChild(entityDef, child.getName());
if (accept(childDef, tested)) {
return true;
}
}
return false;
}
Aggregations