use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class DefaultExpressionEvaluator method getExpressionDependencyMap.
private final Map<Property, List<Property>> getExpressionDependencyMap(Navajo n, List<Property> exprList) throws NavajoException {
Map<Property, List<Property>> depMap = new HashMap<Property, List<Property>>();
for (int i = 0; i < exprList.size(); i++) {
Property current = exprList.get(i);
List<Property> l = getExpressionDependencies(n, current);
depMap.put(current, l);
}
return depMap;
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class DefaultExpressionEvaluator method getExpressionList.
private List<Property> getExpressionList(Navajo n) throws NavajoException {
List<Property> expressionList = new ArrayList<Property>();
List<Message> a = n.getAllMessages();
for (int i = 0; i < a.size(); i++) {
Message current = a.get(i);
getExpressionList(n, current, expressionList);
}
return expressionList;
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class DefaultExpressionEvaluator method createUpdateQueue.
private final List<Property> createUpdateQueue(Map<Property, List<Property>> mm) throws NavajoException {
Map<Property, List<Property>> dependencyMap = duplicateDependencyMap(mm);
Set<Property> propKeys = dependencyMap.keySet();
List<Property> queue = new ArrayList<Property>();
Navajo first = null;
while (dependencyMap.size() > 0) {
for (Iterator<Property> iter = propKeys.iterator(); iter.hasNext(); ) {
Property item = iter.next();
if (first == null) {
first = item.getRootDoc();
}
if (!Property.EXPRESSION_PROPERTY.equals(item.getType())) {
if (!queue.contains(item)) {
queue.add(item);
}
dependencyMap.remove(item);
break;
}
List<Property> deps = dependencyMap.get(item);
if (deps == null) {
if (!queue.contains(item)) {
queue.add(item);
}
dependencyMap.remove(item);
break;
}
if (!containsExpressions(deps)) {
if (!queue.contains(item)) {
queue.add(item);
}
dependencyMap.remove(item);
break;
}
if (queue.containsAll(deps)) {
if (!queue.contains(item)) {
queue.add(item);
}
dependencyMap.remove(item);
break;
}
try {
addExpressionToQueue(item, dependencyMap, queue);
break;
} catch (ExpressionDependencyException ex1) {
logger.info("Did not succeed adding. Continuing", ex1);
}
}
}
// UUUUUUUUUUUGLY: MAKE SURE EVERY SINGLE ONE GETS ADDED
if (first != null) {
queue.addAll(getExpressionList(first));
}
return queue;
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class DefaultExpressionEvaluator method getExpressionList.
private final void getExpressionList(Navajo n, Message m, List<Property> expressionList) throws NavajoException {
List<Message> a = m.getAllMessages();
for (int i = 0; i < a.size(); i++) {
Message current = a.get(i);
getExpressionList(n, current, expressionList);
}
List<Property> b = m.getAllProperties();
for (int i = 0; i < b.size(); i++) {
Property current = b.get(i);
if (current.getType().equals(Property.EXPRESSION_PROPERTY)) {
expressionList.add(current);
}
}
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class DefaultExpressionEvaluator method addExpressionToQueue.
private final void addExpressionToQueue(Property item, Map<Property, List<Property>> depMap, List<Property> queue) throws ExpressionDependencyException {
List<Property> deps = depMap.get(item);
if (deps == null) {
throw new RuntimeException("Huh?");
}
boolean problems = false;
for (int i = 0; i < deps.size(); i++) {
Property p = deps.get(i);
List<Property> deps2 = depMap.get(p);
if (deps2 == null) {
depMap.remove(p);
if (!queue.contains(p)) {
queue.add(p);
}
continue;
}
if (queue.containsAll(deps2)) {
if (!queue.contains(p)) {
queue.add(p);
}
depMap.remove(item);
continue;
}
try {
addExpressionToQueue(p, depMap, queue);
} catch (ExpressionDependencyException ex) {
problems = true;
}
}
if (problems) {
throw new ExpressionDependencyException();
}
}
Aggregations