use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace in project hale by halestudio.
the class WFSGetFeatureWizard method addPages.
@Override
public void addPages() {
super.addPages();
/**
* Page for specifying the WFS capabilities URL.
*/
AbstractWFSCapabilitiesPage<WFSGetFeatureConfig> capPage = new AbstractWFSCapabilitiesPage<WFSGetFeatureConfig>(this) {
@Override
protected boolean updateConfiguration(WFSGetFeatureConfig configuration, URL capabilitiesUrl, WFSCapabilities capabilities) {
if (capabilities != null && capabilities.getGetFeatureOp() != null) {
WFSOperation op = capabilities.getGetFeatureOp();
configuration.setGetFeatureUri(URI.create(op.getHttpGetUrl()));
configuration.setVersion(capabilities.getVersion());
return true;
}
setErrorMessage("Invalid capabilities or WFS does not support GetFeature KVP");
return false;
}
};
addPage(capPage);
addPage(new AbstractFeatureTypesPage<WFSGetFeatureConfig>(this, capPage, "Please specify the feature types to request") {
private boolean selectAll = false;
@Override
protected void updateState(Set<QName> selected) {
// at least one type must be specified
setPageComplete(!selected.isEmpty());
}
@Override
protected Collection<? extends QName> initialSelection(Set<QName> types) {
// select all by default
if (selectAll) {
return types;
}
return super.initialSelection(types);
}
@Override
protected Set<QName> filterTypes(Set<QName> types) {
// relevant types
if (schemaSpaceID != null) {
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
if (ss != null) {
Set<QName> relevantElements = new HashSet<>();
SchemaSpace schemas = ss.getSchemas(schemaSpaceID);
for (TypeDefinition type : schemas.getMappingRelevantTypes()) {
XmlElements elms = type.getConstraint(XmlElements.class);
for (XmlElement elm : elms.getElements()) {
relevantElements.add(elm.getName());
}
}
Set<QName> selection = new HashSet<>(types);
selection.retainAll(relevantElements);
// don't filter if we have no match at all
if (!selection.isEmpty()) {
selectAll = true;
return selection;
}
}
}
selectAll = false;
return super.filterTypes(types);
}
@Override
protected boolean updateConfiguration(WFSGetFeatureConfig configuration, Set<QName> selected) {
configuration.getTypeNames().clear();
configuration.getTypeNames().addAll(selected);
return true;
}
});
// bounding box
addPage(new BBOXPage(this, capPage));
// additional params
addPage(new GetFeatureParamsPage(this));
}
use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace in project hale by halestudio.
the class StyleServiceImpl method getStyle.
private Style getStyle(final DataSet dataset, boolean selected) {
SchemaSpace schemas = schemaService.getSchemas((dataset == DataSet.SOURCE) ? (SchemaSpaceID.SOURCE) : (SchemaSpaceID.TARGET));
Style style = styleFactory.createStyle();
for (TypeDefinition type : schemas.getMappingRelevantTypes()) {
if (!type.getConstraint(AbstractFlag.class).isEnabled()) {
// only add styles for non-abstract feature types
FeatureTypeStyle fts = styles.get(type);
if (fts == null) {
if (fbStyle != null) {
fts = fbStyle;
} else {
fts = StyleHelper.getDefaultStyle(type, dataset);
}
}
if (selected) {
fts = getSelectedStyle(fts);
}
style.featureTypeStyles().add(fts);
}
}
return style;
}
use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace in project hale by halestudio.
the class RootElementPage method updateList.
private void updateList() {
if (// during enable if content not yet created
list != null && getWizard().getProvider() != null) {
// TODO instead of showing all elements allow filtering for elements
// that can hold the type in some form?
SchemaSpace schemas = getWizard().getProvider().getTargetSchema();
XmlIndex index = StreamGmlWriter.getXMLIndex(schemas);
// FIXME use filtered table for selection?
list.setInput(index.getElements().values());
setPageComplete(!list.getSelection().isEmpty());
}
}
use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace in project hale by halestudio.
the class AbstractTargetAction method run.
@Override
public void run() {
// if Display not the active Thread
if (Display.getCurrent() == null) {
// execute in display thread
PlatformUI.getWorkbench().getDisplay().asyncExec(this);
return;
}
if (params == null || params.isEmpty()) {
return;
}
// retrieve the target schema
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
SchemaSpace targetSchema = ss.getSchemas(SchemaSpaceID.TARGET);
// find type
QName typeName = QName.valueOf(params.get(0));
TypeDefinition type = targetSchema.getType(typeName);
if (type == null) {
// check all mapping relevant types for local name only
for (TypeDefinition candidate : targetSchema.getMappingRelevantTypes()) {
if (candidate.getName().getLocalPart().equals(params.get(0))) {
// use the first found
type = candidate;
break;
}
}
}
if (type != null) {
EntityDefinition entity = new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null);
if (params.size() > 1) {
// determine property entity
EntityAccessor accessor = new EntityAccessor(entity);
for (int i = 1; i < params.size(); i++) {
QName propertyName = QName.valueOf(params.get(i));
String namespace = propertyName.getNamespaceURI();
if (namespace != null && namespace.isEmpty()) {
// treat empty namespace as ignoring namespace
namespace = null;
}
accessor = accessor.findChildren(propertyName.getLocalPart(), namespace);
}
entity = accessor.toEntityDefinition();
}
if (entity != null) {
run(entity, manager);
} else {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Schema element not found", "The schema element was not found in the target schema, please make sure the correct schema is loaded.");
}
} else {
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Schema element not found", MessageFormat.format("The type {0} was not found in the target schema, please make sure the correct schema is loaded.", typeName.getLocalPart()));
}
}
use of eu.esdihumboldt.hale.common.schema.model.SchemaSpace in project hale by halestudio.
the class OmlReader method findElementType.
private QName findElementType(TypeIndex schema, QName elementName) {
if (schema instanceof SchemaSpace) {
SchemaSpace ss = (SchemaSpace) schema;
for (Schema schem : ss.getSchemas()) {
if (schem instanceof XmlIndex) {
XmlElement xmlelem = ((XmlIndex) schem).getElements().get(elementName);
if (xmlelem != null) {
return xmlelem.getType().getName();
}
// if there is no element try to find one with an extra "/"
// sign in the namespace because in earlier version this
// case can occur
xmlelem = ((XmlIndex) schem).getElements().get(new QName(elementName.getNamespaceURI() + "/", elementName.getLocalPart()));
if (xmlelem != null) {
return xmlelem.getType().getName();
}
}
}
} else {
for (TypeDefinition typedef : schema.getTypes()) {
XmlElements xmlelem = typedef.getConstraint(XmlElements.class);
for (XmlElement elem : xmlelem.getElements()) {
if (elem.getName().equals(elementName) || elem.getName().equals(new QName(elementName.getNamespaceURI() + "/", elementName.getLocalPart()))) {
return typedef.getName();
}
}
}
}
return elementName;
}
Aggregations