All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cass.rollup.rule.RollupRuleGenerator Maven / Gradle / Ivy

There is a newer version: 3.1.8
Show newest version
package cass.rollup.rule;

import cass.rollup.InquiryPacket;
import org.cass.competency.EcAlignment;
import org.stjs.javascript.functions.Callback1;

public class RollupRuleGenerator {
	public Callback1 failure;
	public Callback1 success;
	private String rule;
	private String outerRule;
	private InquiryPacket ip;

	public RollupRuleGenerator(InquiryPacket ip) {
		this.ip = ip;
		rule = "";
		outerRule = "";
	}

	public void go() {
		final RollupRuleGenerator me = this;
		if (ip.getContext().relation == null)
			success.$invoke(null);
		else
			for (int i = 0; i < ip.getContext().relation.$length(); i++) {
				ip.numberOfQueriesRunning++;
				EcAlignment.get(ip.getContext().relation.$get(i), new Callback1() {
					@Override
					public void $invoke(EcAlignment p1) {
						me.ip.numberOfQueriesRunning--;
						if (!p1.source.equals(me.ip.competency) && !p1.target.equals(me.ip.competency))
							return;
						if (p1.source.equals(me.ip.competency)) {
							if (p1.relationType.equals(EcAlignment.REQUIRES)) {
								if (me.rule != null && me.rule != "")
									me.rule += " AND ";
								me.rule += "[notNegative competency:\"" + p1.target + "\"]";
							}
							if (p1.relationType.equals(EcAlignment.NARROWS)) {
								if (me.outerRule != null && me.outerRule != "")
									me.outerRule += " OR ";
								me.outerRule += "[competency:\"" + p1.target + "\"]";
							}
						}
					}
				}, new Callback1() {
					@Override
					public void $invoke(String p1) {
						me.ip.numberOfQueriesRunning--;
					}
				});
			}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy