use of eu.esdihumboldt.hale.common.schema.model.ChildDefinition in project hale by halestudio.
the class PropertyResolver method analyzeSpecialQueryChildDefinition.
/**
* this method searches for the indices given from the querypath inside the
* instance-definition-tree the indices must be children in order to their
* appearance in the path. only groups may be between them. the method
* writes the found paths into the cache
*
* @param children a list of Childdefinitions from the rootdefinition of the
* instance-definition-tree
* @param path the list of QNames split up from the original querypath
* @param qdi the cacheindex produced from the instance root definition and
* the querypath
*/
private static void analyzeSpecialQueryChildDefinition(Collection<? extends ChildDefinition<?>> children, List<QName> path, QueryDefinitionIndex qdi) {
QName current = path.get(0);
Queue<QueueDefinitionItem> propertyqueue = new LinkedList<QueueDefinitionItem>();
Iterator<? extends ChildDefinition<?>> childIterator = children.iterator();
while (childIterator.hasNext()) {
ChildDefinition<?> child = childIterator.next();
QueueDefinitionItem queueItem = new QueueDefinitionItem(child, child.getName());
propertyqueue.add(queueItem);
}
while (!propertyqueue.isEmpty()) {
QueueDefinitionItem currentItem = propertyqueue.poll();
if (compareQName(current, currentItem.getDefinition().getName()) && isProperty(currentItem.getDefinition())) {
for (int i = 1; i < path.size(); i++) {
currentItem = analyzeSubChild(currentItem, path.get(i));
if (currentItem == null) {
break;
}
}
if (currentItem != null) {
definitioncache.get(qdi).add(currentItem.qNamesToString());
}
} else if (isGroup(currentItem.getDefinition())) {
Iterator<? extends ChildDefinition<?>> tempit;
tempit = currentItem.getDefinition().asGroup().getDeclaredChildren().iterator();
while (tempit.hasNext()) {
ChildDefinition<?> tempdef = tempit.next();
// a list of lists
if (currentItem.getLoopQNames().contains(tempdef.getName())) {
continue;
}
if (currentItem.getQnames().contains(tempdef.getName())) {
ArrayList<QName> loops = new ArrayList<QName>();
for (int i = currentItem.getQnames().indexOf(tempdef.getName()); i < currentItem.getQnames().size(); i++) {
loops.add(currentItem.getQnames().get(i));
}
currentItem.addLoopQNames(loops);
continue;
}
QueueDefinitionItem qudi = new QueueDefinitionItem(tempdef, tempdef.getName());
qudi.addQnames(currentItem.getQnames());
for (List<QName> loop : currentItem.getLoopQNames()) {
qudi.addLoopQNames(loop);
}
propertyqueue.add(qudi);
}
}
}
}
use of eu.esdihumboldt.hale.common.schema.model.ChildDefinition in project hale by halestudio.
the class PropertyEntityDialog method getObjectFromSelection.
/**
* @see EntityDialog#getObjectFromSelection(ISelection)
*/
@Override
protected EntityDefinition getObjectFromSelection(ISelection selection) {
if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
Object element = ((IStructuredSelection) selection).getFirstElement();
if (element instanceof EntityDefinition) {
return (EntityDefinition) element;
}
}
if (!selection.isEmpty() && selection instanceof ITreeSelection) {
// create property definition w/ default contexts
TreePath path = ((ITreeSelection) selection).getPaths()[0];
// get parent type
TypeDefinition type = ((PropertyDefinition) path.getFirstSegment()).getParentType();
// determine definition path
List<ChildContext> defPath = new ArrayList<ChildContext>();
for (int i = 0; i < path.getSegmentCount(); i++) {
defPath.add(new ChildContext((ChildDefinition<?>) path.getSegment(i)));
}
// TODO check if property entity definition is applicable?
return new PropertyEntityDefinition(type, defPath, ssid, parentType.getFilter());
}
return null;
}
Aggregations