Java Code Examples for ims.rules.interfaces.IRule

The following are top voted examples for showing how to use ims.rules.interfaces.IRule. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: AvoinApotti   File: Logic.java   Source Code and License 6 votes vote down vote up
private void open() throws PresentationLogicException
{
	// populate Root Entity
	populateRootEntity();

	BusinessRuleVo editedRule = form.getLocalContext().getEditedRule();

	// If any edited rule, display it
	if (editedRule != null)
	{
		IRule rule;
		try
		{
			rule = RuleXmlSerialization.deserializeFromXml(editedRule.getXmlContent(), Entities.getInstance());
			displayRule(rule, editedRule);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			throw new DomainRuntimeException(e.toString());
		}
	}
	updateContextMenu();
}
 
Example 2
Project: AvoinApotti   File: Logic.java   Source Code and License 6 votes vote down vote up
@Override
protected void onlyrRulesTabChanged(LayerBridge tab)
{

	if (tab.equals(form.lyrRules().tabOverview()))
	{
		IRule rule = getRuleFromScreen();
		StringBuilder sb = new StringBuilder();
		sb.append("<b>IF</b><br>");
		int tabs = 0;
		for (int x = 0; x < rule.getConditions().size(); x++)
		{
			renderCondition(sb, rule.getConditions().get(x), rule, tabs);
		}

		form.lyrRules().tabOverview().htmOverview().setHTML(sb.toString());
	}

}
 
Example 3
Project: AvoinApotti   File: Logic.java   Source Code and License 6 votes vote down vote up
private void renderValueCondition(StringBuilder sb, RuleValueConditionEntry entry, boolean isRoot, IRule rule)
{
	if (isRoot)
	{
		sb.append(rule.getRootEntity().getName());
		isRoot = false;
	}

	if (entry.getField() != null)
	{
		sb.append(entry.getField().getFieldGetter().replace("get", "").replace("()", ""));
	}

	if (entry.getChild() != null)
	{
		sb.append("<b>-></b>");
		renderValueCondition(sb, entry.getChild(), isRoot, rule);
	}
}
 
Example 4
Project: AvoinApotti   File: Logic.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBtnPreviewClick() throws PresentationLogicException 
{
	IRule rule = form.cc1RuleEditor().getIRule();
	if(rule != null)
	{
		String xml;
		try {
			xml = RuleXmlSerialization.serialize(rule);
			form.getGlobalContext().Rules.RulesCodePreview.setXmlRule(xml);
			engine.open(form.getForms().Rules.RuleCodePreview);
		} 
		catch (RulesEngineSerializationException e) {		
			e.printStackTrace();
		}					
	}
}
 
Example 5
Project: openMAXIMS   File: Logic.java   Source Code and License 6 votes vote down vote up
private void open() throws PresentationLogicException
{
	// populate Root Entity
	populateRootEntity();

	BusinessRuleVo editedRule = form.getLocalContext().getEditedRule();

	// If any edited rule, display it
	if (editedRule != null)
	{
		IRule rule;
		try
		{
			rule = RuleXmlSerialization.deserializeFromXml(editedRule.getXmlContent(), Entities.getInstance());
			displayRule(rule, editedRule);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			throw new DomainRuntimeException(e.toString());
		}
	}
	updateContextMenu();
}
 
Example 6
Project: openMAXIMS   File: Logic.java   Source Code and License 6 votes vote down vote up
@Override
protected void onlyrRulesTabChanged(LayerBridge tab)
{

	if (tab.equals(form.lyrRules().tabOverview()))
	{
		IRule rule = getRuleFromScreen();
		StringBuilder sb = new StringBuilder();
		sb.append("<b>IF</b><br>");
		int tabs = 0;
		for (int x = 0; x < rule.getConditions().size(); x++)
		{
			renderCondition(sb, rule.getConditions().get(x), rule, tabs);
		}

		form.lyrRules().tabOverview().htmOverview().setHTML(sb.toString());
	}

}
 
Example 7
Project: openMAXIMS   File: Logic.java   Source Code and License 6 votes vote down vote up
private void renderValueCondition(StringBuilder sb, RuleValueConditionEntry entry, boolean isRoot, IRule rule)
{
	if (isRoot)
	{
		sb.append(rule.getRootEntity().getName());
		isRoot = false;
	}

	if (entry.getField() != null)
	{
		sb.append(entry.getField().getFieldGetter().replace("get", "").replace("()", ""));
	}

	if (entry.getChild() != null)
	{
		sb.append("<b>-></b>");
		renderValueCondition(sb, entry.getChild(), isRoot, rule);
	}
}
 
Example 8
Project: openMAXIMS   File: Logic.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBtnPreviewClick() throws PresentationLogicException 
{
	IRule rule = form.cc1RuleEditor().getIRule();
	if(rule != null)
	{
		String xml;
		try {
			xml = RuleXmlSerialization.serialize(rule);
			form.getGlobalContext().Rules.RulesCodePreview.setXmlRule(xml);
			engine.open(form.getForms().Rules.RuleCodePreview);
		} 
		catch (RulesEngineSerializationException e) {		
			e.printStackTrace();
		}					
	}
}
 
Example 9
Project: openMAXIMS   File: Logic.java   Source Code and License 6 votes vote down vote up
private void open() throws PresentationLogicException
{
	// populate Root Entity
	populateRootEntity();

	BusinessRuleVo editedRule = form.getLocalContext().getEditedRule();

	// If any edited rule, display it
	if (editedRule != null)
	{
		IRule rule;
		try
		{
			rule = RuleXmlSerialization.deserializeFromXml(editedRule.getXmlContent(), Entities.getInstance());
			displayRule(rule, editedRule);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			throw new DomainRuntimeException(e.toString());
		}
	}
	updateContextMenu();
}
 
Example 10
Project: openMAXIMS   File: Logic.java   Source Code and License 6 votes vote down vote up
@Override
protected void onlyrRulesTabChanged(LayerBridge tab)
{

	if (tab.equals(form.lyrRules().tabOverview()))
	{
		IRule rule = getRuleFromScreen();
		StringBuilder sb = new StringBuilder();
		sb.append("<b>IF</b><br>");
		int tabs = 0;
		for (int x = 0; x < rule.getConditions().size(); x++)
		{
			renderCondition(sb, rule.getConditions().get(x), rule, tabs);
		}

		form.lyrRules().tabOverview().htmOverview().setHTML(sb.toString());
	}

}
 
Example 11
Project: openMAXIMS   File: Logic.java   Source Code and License 6 votes vote down vote up
private void renderValueCondition(StringBuilder sb, RuleValueConditionEntry entry, boolean isRoot, IRule rule)
{
	if (isRoot)
	{
		sb.append(rule.getRootEntity().getName());
		isRoot = false;
	}

	if (entry.getField() != null)
	{
		sb.append(entry.getField().getFieldGetter().replace("get", "").replace("()", ""));
	}

	if (entry.getChild() != null)
	{
		sb.append("<b>-></b>");
		renderValueCondition(sb, entry.getChild(), isRoot, rule);
	}
}
 
Example 12
Project: openMAXIMS   File: Logic.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBtnPreviewClick() throws PresentationLogicException 
{
	IRule rule = form.cc1RuleEditor().getIRule();
	if(rule != null)
	{
		String xml;
		try {
			xml = RuleXmlSerialization.serialize(rule);
			form.getGlobalContext().Rules.RulesCodePreview.setXmlRule(xml);
			engine.open(form.getForms().Rules.RuleCodePreview);
		} 
		catch (RulesEngineSerializationException e) {		
			e.printStackTrace();
		}					
	}
}
 
Example 13
Project: openmaxims-linux   File: Logic.java   Source Code and License 6 votes vote down vote up
private void open() throws PresentationLogicException
{
	// populate Root Entity
	populateRootEntity();

	BusinessRuleVo editedRule = form.getLocalContext().getEditedRule();

	// If any edited rule, display it
	if (editedRule != null)
	{
		IRule rule;
		try
		{
			rule = RuleXmlSerialization.deserializeFromXml(editedRule.getXmlContent(), Entities.getInstance());
			displayRule(rule, editedRule);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			throw new DomainRuntimeException(e.toString());
		}
	}
	updateContextMenu();
}
 
Example 14
Project: openmaxims-linux   File: Logic.java   Source Code and License 6 votes vote down vote up
@Override
protected void onlyrRulesTabChanged(LayerBridge tab)
{

	if (tab.equals(form.lyrRules().tabOverview()))
	{
		IRule rule = getRuleFromScreen();
		StringBuilder sb = new StringBuilder();
		sb.append("<b>IF</b><br>");
		int tabs = 0;
		for (int x = 0; x < rule.getConditions().size(); x++)
		{
			renderCondition(sb, rule.getConditions().get(x), rule, tabs);
		}

		form.lyrRules().tabOverview().htmOverview().setHTML(sb.toString());
	}

}
 
Example 15
Project: openmaxims-linux   File: Logic.java   Source Code and License 6 votes vote down vote up
private void renderValueCondition(StringBuilder sb, RuleValueConditionEntry entry, boolean isRoot, IRule rule)
{
	if (isRoot)
	{
		sb.append(rule.getRootEntity().getName());
		isRoot = false;
	}

	if (entry.getField() != null)
	{
		sb.append(entry.getField().getFieldGetter().replace("get", "").replace("()", ""));
	}

	if (entry.getChild() != null)
	{
		sb.append("<b>-></b>");
		renderValueCondition(sb, entry.getChild(), isRoot, rule);
	}
}
 
Example 16
Project: openmaxims-linux   File: Logic.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBtnPreviewClick() throws PresentationLogicException 
{
	IRule rule = form.cc1RuleEditor().getIRule();
	if(rule != null)
	{
		String xml;
		try {
			xml = RuleXmlSerialization.serialize(rule);
			form.getGlobalContext().Rules.RulesCodePreview.setXmlRule(xml);
			engine.open(form.getForms().Rules.RuleCodePreview);
		} 
		catch (RulesEngineSerializationException e) {		
			e.printStackTrace();
		}					
	}
}
 
Example 17
Project: AvoinApotti   File: Logic.java   Source Code and License 5 votes vote down vote up
private void renderCondition(StringBuilder sb, IRuleCondition condition, IRule rule, int tabs)
{
	if (condition instanceof RuleLogicalCondition)
	{
		renderLogicalCondition(sb, (RuleLogicalCondition) condition, rule, tabs);
	}
	else if (condition instanceof RuleValueCondition)
	{

		sb.append("(");
		renderValueCondition(sb, (RuleValueCondition) condition, rule);
		sb.append(")");
	}
}
 
Example 18
Project: AvoinApotti   File: Logic.java   Source Code and License 5 votes vote down vote up
private void renderValueCondition(StringBuilder sb, RuleValueCondition condition, IRule rule)
{
	StringBuilder valueConditionString = new StringBuilder();
	renderValueCondition(valueConditionString, condition.getEntry(), true, rule);

	sb.append(valueConditionString.toString());
	sb.append(getRuleComparator(condition.getComparator(), condition.getComparedValue()));
}
 
Example 19
Project: AvoinApotti   File: RulesPriorityEditorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
public BusinessRuleVoCollection save(BusinessRuleVoCollection rules) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	if (rules == null)
		throw new CodingRuntimeException("Major Logical Error - Rules collection must not be null");
	
	DomainFactory factory = getDomainFactory();
	
	for (int i = 0; i < rules.size(); i++)
	{
		BusinessRuleVo rule = rules.get(i);
		BusinessRule domRule = BusinessRuleVoAssembler.extractBusinessRule(factory, rule);			
		
		if (rule.getXmlContent() == null)
			throw new CodingRuntimeException("Major Logical Error - XML Content cannot be null");
		
		String xml;
		try {
			IRule iRule = RuleXmlSerialization.deserializeFromXml(rule.getXmlContent(), Entities.getInstance());
			iRule.setPriority(rule.getPriority());
			xml = RuleXmlSerialization.serialize(iRule);
			domRule.setXmlContent(xml);
			factory.save(domRule);
		}
		catch (Exception e) 
		{
			throw new DomainInterfaceException(e.getMessage());				
		}				
	}
	
	// Return null
	return null;
}
 
Example 20
Project: openMAXIMS   File: Logic.java   Source Code and License 5 votes vote down vote up
private void renderCondition(StringBuilder sb, IRuleCondition condition, IRule rule, int tabs)
{
	if (condition instanceof RuleLogicalCondition)
	{
		renderLogicalCondition(sb, (RuleLogicalCondition) condition, rule, tabs);
	}
	else if (condition instanceof RuleValueCondition)
	{

		sb.append("(");
		renderValueCondition(sb, (RuleValueCondition) condition, rule);
		sb.append(")");
	}
}
 
Example 21
Project: openMAXIMS   File: Logic.java   Source Code and License 5 votes vote down vote up
private void renderValueCondition(StringBuilder sb, RuleValueCondition condition, IRule rule)
{
	StringBuilder valueConditionString = new StringBuilder();
	renderValueCondition(valueConditionString, condition.getEntry(), true, rule);

	sb.append(valueConditionString.toString());
	sb.append(getRuleComparator(condition.getComparator(), condition.getComparedValue()));
}
 
Example 22
Project: openMAXIMS   File: RulesPriorityEditorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
public BusinessRuleVoCollection save(BusinessRuleVoCollection rules) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	if (rules == null)
		throw new CodingRuntimeException("Major Logical Error - Rules collection must not be null");
	
	DomainFactory factory = getDomainFactory();
	
	for (int i = 0; i < rules.size(); i++)
	{
		BusinessRuleVo rule = rules.get(i);
		BusinessRule domRule = BusinessRuleVoAssembler.extractBusinessRule(factory, rule);			
		
		if (rule.getXmlContent() == null)
			throw new CodingRuntimeException("Major Logical Error - XML Content cannot be null");
		
		String xml;
		try {
			IRule iRule = RuleXmlSerialization.deserializeFromXml(rule.getXmlContent(), Entities.getInstance());
			iRule.setPriority(rule.getPriority());
			xml = RuleXmlSerialization.serialize(iRule);
			domRule.setXmlContent(xml);
			factory.save(domRule);
		}
		catch (Exception e) 
		{
			throw new DomainInterfaceException(e.getMessage());				
		}				
	}
	
	// Return null
	return null;
}
 
Example 23
Project: openMAXIMS   File: Logic.java   Source Code and License 5 votes vote down vote up
private void renderCondition(StringBuilder sb, IRuleCondition condition, IRule rule, int tabs)
{
	if (condition instanceof RuleLogicalCondition)
	{
		renderLogicalCondition(sb, (RuleLogicalCondition) condition, rule, tabs);
	}
	else if (condition instanceof RuleValueCondition)
	{

		sb.append("(");
		renderValueCondition(sb, (RuleValueCondition) condition, rule);
		sb.append(")");
	}
}
 
Example 24
Project: openMAXIMS   File: Logic.java   Source Code and License 5 votes vote down vote up
private void renderValueCondition(StringBuilder sb, RuleValueCondition condition, IRule rule)
{
	StringBuilder valueConditionString = new StringBuilder();
	renderValueCondition(valueConditionString, condition.getEntry(), true, rule);

	sb.append(valueConditionString.toString());
	sb.append(getRuleComparator(condition.getComparator(), condition.getComparedValue()));
}
 
Example 25
Project: openMAXIMS   File: RulesPriorityEditorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
public BusinessRuleVoCollection save(BusinessRuleVoCollection rules) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	if (rules == null)
		throw new CodingRuntimeException("Major Logical Error - Rules collection must not be null");
	
	DomainFactory factory = getDomainFactory();
	
	for (int i = 0; i < rules.size(); i++)
	{
		BusinessRuleVo rule = rules.get(i);
		BusinessRule domRule = BusinessRuleVoAssembler.extractBusinessRule(factory, rule);			
		
		if (rule.getXmlContent() == null)
			throw new CodingRuntimeException("Major Logical Error - XML Content cannot be null");
		
		String xml;
		try {
			IRule iRule = RuleXmlSerialization.deserializeFromXml(rule.getXmlContent(), Entities.getInstance());
			iRule.setPriority(rule.getPriority());
			xml = RuleXmlSerialization.serialize(iRule);
			domRule.setXmlContent(xml);
			factory.save(domRule);
		}
		catch (Exception e) 
		{
			throw new DomainInterfaceException(e.getMessage());				
		}				
	}
	
	// Return null
	return null;
}
 
Example 26
Project: openmaxims-linux   File: Logic.java   Source Code and License 5 votes vote down vote up
private void renderCondition(StringBuilder sb, IRuleCondition condition, IRule rule, int tabs)
{
	if (condition instanceof RuleLogicalCondition)
	{
		renderLogicalCondition(sb, (RuleLogicalCondition) condition, rule, tabs);
	}
	else if (condition instanceof RuleValueCondition)
	{

		sb.append("(");
		renderValueCondition(sb, (RuleValueCondition) condition, rule);
		sb.append(")");
	}
}
 
Example 27
Project: openmaxims-linux   File: Logic.java   Source Code and License 5 votes vote down vote up
private void renderValueCondition(StringBuilder sb, RuleValueCondition condition, IRule rule)
{
	StringBuilder valueConditionString = new StringBuilder();
	renderValueCondition(valueConditionString, condition.getEntry(), true, rule);

	sb.append(valueConditionString.toString());
	sb.append(getRuleComparator(condition.getComparator(), condition.getComparedValue()));
}
 
Example 28
Project: openmaxims-linux   File: RulesPriorityEditorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * 
 */
public BusinessRuleVoCollection save(BusinessRuleVoCollection rules) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException
{
	if (rules == null)
		throw new CodingRuntimeException("Major Logical Error - Rules collection must not be null");
	
	DomainFactory factory = getDomainFactory();
	
	for (int i = 0; i < rules.size(); i++)
	{
		BusinessRuleVo rule = rules.get(i);
		BusinessRule domRule = BusinessRuleVoAssembler.extractBusinessRule(factory, rule);			
		
		if (rule.getXmlContent() == null)
			throw new CodingRuntimeException("Major Logical Error - XML Content cannot be null");
		
		String xml;
		try {
			IRule iRule = RuleXmlSerialization.deserializeFromXml(rule.getXmlContent(), Entities.getInstance());
			iRule.setPriority(rule.getPriority());
			xml = RuleXmlSerialization.serialize(iRule);
			domRule.setXmlContent(xml);
			factory.save(domRule);
		}
		catch (Exception e) 
		{
			throw new DomainInterfaceException(e.getMessage());				
		}				
	}
	
	// Return null
	return null;
}
 
Example 29
Project: AvoinApotti   File: Logic.java   Source Code and License 4 votes vote down vote up
private IRule getRuleFromScreen()
{
	Rule rule = new Rule();

	rule.setName(form.lyrRules().tabGeneral().txtName().getValue());
	rule.setDescription(form.lyrRules().tabGeneral().txtDescription().getValue());
	rule.setPriority(0);
	if (form.lyrRules().tabGeneral().chkDateRange().getValue())
	{
		rule.setValidFrom(form.lyrRules().tabGeneral().dteValidFrom().getValue());
		rule.setValidTo(form.lyrRules().tabGeneral().dteValidTo().getValue());
	}
	else
	{
		rule.setValidFrom(null);
		rule.setValidTo(null);
	}

	rule.setRootEntity(form.lyrRules().tabConditions().cmbRootEntity().getValue());

	List<IRuleCondition> conditions = new ArrayList<IRuleCondition>();
	List<IRuleCondition> valueConditions = new ArrayList<IRuleCondition>();

	int numberOfRows = form.lyrRules().tabConditions().dyngrdConditions().getRows().size();
	RuleLogicalCondition logicalCondition = null;
	RuleValueConditionEntry entry = null;

	for (int i = 0; i < numberOfRows; i++)
	{
		DynamicGridRow row = form.lyrRules().tabConditions().dyngrdConditions().getRows().get(i);
		RuleConditionRowVo rowIdentifier = (RuleConditionRowVo) row.getIdentifier();
		int numberOfColums = rowIdentifier.getNumberOfColumns();

		if (rowIdentifier != null)
		{
			logicalCondition = checkForLogicalCondition(logicalCondition, row, rowIdentifier, numberOfColums);
			if (row.getRows() != null)
			{
				entry = checkForChildValueCondition(valueConditions, entry, row);
			}
		}
	}

	if (entry == null)
		return null;

	logicalCondition.setConditions(valueConditions);
	conditions.add(logicalCondition);
	rule.setConditions(conditions);

	rule.setActions(getActions());

	return rule;
}
 
Example 30
Project: AvoinApotti   File: Logic.java   Source Code and License 4 votes vote down vote up
private void renderLogicalCondition(StringBuilder sb, RuleLogicalCondition condition, IRule rule, int tabs)
{

	if (tabs == 0)
	{
		sb.append("<b>{</b><br>");
	}
	else
	{
		sb.append("<b><br>{</b>");
	}
	for (int x = 0; x < condition.getConditions().size(); x++)
	{
		if (x > 0)
		{
			if (condition.equals(RuleLogicalCondition.getInstance(RuleLogicalConditionType.ALLTRUE)))
			{
				sb.append("<b>  &&  </b> ");
				tabs = 1;
			}
			/*
			 * else if(condition.equals(RuleLogicalCondition.getInstance(
			 * RuleLogicalConditionType.ALLFALSE))) {
			 * sb.append("<b>  &&  </b> "); tabs=1; }
			 */
			else if (condition.equals(RuleLogicalCondition.getInstance(RuleLogicalConditionType.ONETRUE)))
			{
				sb.append("<b>  ||  </b> ");
				tabs = 1;
			}
			/*
			 * else if(condition.equals(RuleLogicalCondition.getInstance(
			 * RuleLogicalConditionType.ONEFALSE))) {
			 * sb.append("<b>  ||  </b> "); tabs=1; }
			 */
		}

		renderCondition(sb, condition.getConditions().get(x), rule, tabs);
	}
	sb.append("<b>}</b><br>");
}
 
Example 31
Project: AvoinApotti   File: UserRulesProvider.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public IRule[] getUserRules() 
{				
	DomainFactory factory = getDomainFactory();
	StringBuffer hql = new StringBuffer(" from BusinessRule br where br.active = 1");
	List lst = factory.find(hql.toString());
	 
	if (lst != null)
	{
		List<IRule> rules = new ArrayList<IRule>();
		
		Iterator<Object> i = lst.iterator();
		
		while(i.hasNext())
		{
			BusinessRule dbRule = (BusinessRule)i.next();
			
			if (dbRule != null)
			{
				String xmlContent = dbRule.getXmlContent();
				if (xmlContent != null)
				{
					IRule rule;
					try 
					{
						rule = RuleXmlSerialization.deserializeFromXml(xmlContent, ims.rules.helper.Entities.getInstance());							
						rules.add(rule);
					} 
					catch (Exception e) 
					{
						// Nothing else to do so far, I will throw a runtime exception later...
						e.printStackTrace();
					} 
				}
			}
		}		
		
		IRule[] collection = new IRule[rules.size()];
		rules.toArray(collection);
		return collection;						
	}
			
	return null;	
}
 
Example 32
Project: AvoinApotti   File: UserRulesProvider.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public IRule[] getUserRules() 
{				
	DomainFactory factory = getDomainFactory();
	StringBuffer hql = new StringBuffer(" from BusinessRule br where br.active = 1");
	List lst = factory.find(hql.toString());
	 
	if (lst != null)
	{
		List<IRule> rules = new ArrayList<IRule>();
		
		Iterator<Object> i = lst.iterator();
		
		while(i.hasNext())
		{
			BusinessRule dbRule = (BusinessRule)i.next();
			
			if (dbRule != null)
			{
				String xmlContent = dbRule.getXmlContent();
				if (xmlContent != null)
				{
					IRule rule;
					try 
					{
						rule = RuleXmlSerialization.deserializeFromXml(xmlContent, ims.rules.helper.Entities.getInstance());							
						rules.add(rule);
					} 
					catch (Exception e) 
					{
						// Nothing else to do so far, I will throw a runtime exception later...
						e.printStackTrace();
					} 
				}
			}
		}		
		
		IRule[] collection = new IRule[rules.size()];
		rules.toArray(collection);
		return collection;						
	}
			
	return null;	
}
 
Example 33
Project: openMAXIMS   File: Logic.java   Source Code and License 4 votes vote down vote up
private IRule getRuleFromScreen()
{
	Rule rule = new Rule();

	rule.setName(form.lyrRules().tabGeneral().txtName().getValue());
	rule.setDescription(form.lyrRules().tabGeneral().txtDescription().getValue());
	rule.setPriority(0);
	if (form.lyrRules().tabGeneral().chkDateRange().getValue())
	{
		rule.setValidFrom(form.lyrRules().tabGeneral().dteValidFrom().getValue());
		rule.setValidTo(form.lyrRules().tabGeneral().dteValidTo().getValue());
	}
	else
	{
		rule.setValidFrom(null);
		rule.setValidTo(null);
	}

	rule.setRootEntity(form.lyrRules().tabConditions().cmbRootEntity().getValue());

	List<IRuleCondition> conditions = new ArrayList<IRuleCondition>();
	List<IRuleCondition> valueConditions = new ArrayList<IRuleCondition>();

	int numberOfRows = form.lyrRules().tabConditions().dyngrdConditions().getRows().size();
	RuleLogicalCondition logicalCondition = null;
	RuleValueConditionEntry entry = null;

	for (int i = 0; i < numberOfRows; i++)
	{
		DynamicGridRow row = form.lyrRules().tabConditions().dyngrdConditions().getRows().get(i);
		RuleConditionRowVo rowIdentifier = (RuleConditionRowVo) row.getIdentifier();
		int numberOfColums = rowIdentifier.getNumberOfColumns();

		if (rowIdentifier != null)
		{
			logicalCondition = checkForLogicalCondition(logicalCondition, row, rowIdentifier, numberOfColums);
			if (row.getRows() != null)
			{
				entry = checkForChildValueCondition(valueConditions, entry, row);
			}
		}
	}

	if (entry == null)
		return null;

	logicalCondition.setConditions(valueConditions);
	conditions.add(logicalCondition);
	rule.setConditions(conditions);

	rule.setActions(getActions());

	return rule;
}
 
Example 34
Project: openMAXIMS   File: Logic.java   Source Code and License 4 votes vote down vote up
private void renderLogicalCondition(StringBuilder sb, RuleLogicalCondition condition, IRule rule, int tabs)
{

	if (tabs == 0)
	{
		sb.append("<b>{</b><br>");
	}
	else
	{
		sb.append("<b><br>{</b>");
	}
	for (int x = 0; x < condition.getConditions().size(); x++)
	{
		if (x > 0)
		{
			if (condition.equals(RuleLogicalCondition.getInstance(RuleLogicalConditionType.ALLTRUE)))
			{
				sb.append("<b>  &&  </b> ");
				tabs = 1;
			}
			/*
			 * else if(condition.equals(RuleLogicalCondition.getInstance(
			 * RuleLogicalConditionType.ALLFALSE))) {
			 * sb.append("<b>  &&  </b> "); tabs=1; }
			 */
			else if (condition.equals(RuleLogicalCondition.getInstance(RuleLogicalConditionType.ONETRUE)))
			{
				sb.append("<b>  ||  </b> ");
				tabs = 1;
			}
			/*
			 * else if(condition.equals(RuleLogicalCondition.getInstance(
			 * RuleLogicalConditionType.ONEFALSE))) {
			 * sb.append("<b>  ||  </b> "); tabs=1; }
			 */
		}

		renderCondition(sb, condition.getConditions().get(x), rule, tabs);
	}
	sb.append("<b>}</b><br>");
}
 
Example 35
Project: openMAXIMS   File: UserRulesProvider.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public IRule[] getUserRules() 
{				
	DomainFactory factory = getDomainFactory();
	StringBuffer hql = new StringBuffer(" from BusinessRule br where br.active = 1");
	List lst = factory.find(hql.toString());
	 
	if (lst != null)
	{
		List<IRule> rules = new ArrayList<IRule>();
		
		Iterator<Object> i = lst.iterator();
		
		while(i.hasNext())
		{
			BusinessRule dbRule = (BusinessRule)i.next();
			
			if (dbRule != null)
			{
				String xmlContent = dbRule.getXmlContent();
				if (xmlContent != null)
				{
					IRule rule;
					try 
					{
						rule = RuleXmlSerialization.deserializeFromXml(xmlContent, ims.rules.helper.Entities.getInstance());							
						rules.add(rule);
					} 
					catch (Exception e) 
					{
						// Nothing else to do so far, I will throw a runtime exception later...
						e.printStackTrace();
					} 
				}
			}
		}		
		
		IRule[] collection = new IRule[rules.size()];
		rules.toArray(collection);
		return collection;						
	}
			
	return null;	
}
 
Example 36
Project: openMAXIMS   File: Logic.java   Source Code and License 4 votes vote down vote up
private IRule getRuleFromScreen()
{
	Rule rule = new Rule();

	rule.setName(form.lyrRules().tabGeneral().txtName().getValue());
	rule.setDescription(form.lyrRules().tabGeneral().txtDescription().getValue());
	rule.setPriority(0);
	if (form.lyrRules().tabGeneral().chkDateRange().getValue())
	{
		rule.setValidFrom(form.lyrRules().tabGeneral().dteValidFrom().getValue());
		rule.setValidTo(form.lyrRules().tabGeneral().dteValidTo().getValue());
	}
	else
	{
		rule.setValidFrom(null);
		rule.setValidTo(null);
	}

	rule.setRootEntity(form.lyrRules().tabConditions().cmbRootEntity().getValue());

	List<IRuleCondition> conditions = new ArrayList<IRuleCondition>();
	List<IRuleCondition> valueConditions = new ArrayList<IRuleCondition>();

	int numberOfRows = form.lyrRules().tabConditions().dyngrdConditions().getRows().size();
	RuleLogicalCondition logicalCondition = null;
	RuleValueConditionEntry entry = null;

	for (int i = 0; i < numberOfRows; i++)
	{
		DynamicGridRow row = form.lyrRules().tabConditions().dyngrdConditions().getRows().get(i);
		RuleConditionRowVo rowIdentifier = (RuleConditionRowVo) row.getIdentifier();
		int numberOfColums = rowIdentifier.getNumberOfColumns();

		if (rowIdentifier != null)
		{
			logicalCondition = checkForLogicalCondition(logicalCondition, row, rowIdentifier, numberOfColums);
			if (row.getRows() != null)
			{
				entry = checkForChildValueCondition(valueConditions, entry, row);
			}
		}
	}

	if (entry == null)
		return null;

	logicalCondition.setConditions(valueConditions);
	conditions.add(logicalCondition);
	rule.setConditions(conditions);

	rule.setActions(getActions());

	return rule;
}
 
Example 37
Project: openMAXIMS   File: Logic.java   Source Code and License 4 votes vote down vote up
private void renderLogicalCondition(StringBuilder sb, RuleLogicalCondition condition, IRule rule, int tabs)
{

	if (tabs == 0)
	{
		sb.append("<b>{</b><br>");
	}
	else
	{
		sb.append("<b><br>{</b>");
	}
	for (int x = 0; x < condition.getConditions().size(); x++)
	{
		if (x > 0)
		{
			if (condition.equals(RuleLogicalCondition.getInstance(RuleLogicalConditionType.ALLTRUE)))
			{
				sb.append("<b>  &&  </b> ");
				tabs = 1;
			}
			/*
			 * else if(condition.equals(RuleLogicalCondition.getInstance(
			 * RuleLogicalConditionType.ALLFALSE))) {
			 * sb.append("<b>  &&  </b> "); tabs=1; }
			 */
			else if (condition.equals(RuleLogicalCondition.getInstance(RuleLogicalConditionType.ONETRUE)))
			{
				sb.append("<b>  ||  </b> ");
				tabs = 1;
			}
			/*
			 * else if(condition.equals(RuleLogicalCondition.getInstance(
			 * RuleLogicalConditionType.ONEFALSE))) {
			 * sb.append("<b>  ||  </b> "); tabs=1; }
			 */
		}

		renderCondition(sb, condition.getConditions().get(x), rule, tabs);
	}
	sb.append("<b>}</b><br>");
}
 
Example 38
Project: openMAXIMS   File: UserRulesProvider.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public IRule[] getUserRules() 
{				
	DomainFactory factory = getDomainFactory();
	StringBuffer hql = new StringBuffer(" from BusinessRule br where br.active = 1");
	List lst = factory.find(hql.toString());
	 
	if (lst != null)
	{
		List<IRule> rules = new ArrayList<IRule>();
		
		Iterator<Object> i = lst.iterator();
		
		while(i.hasNext())
		{
			BusinessRule dbRule = (BusinessRule)i.next();
			
			if (dbRule != null)
			{
				String xmlContent = dbRule.getXmlContent();
				if (xmlContent != null)
				{
					IRule rule;
					try 
					{
						rule = RuleXmlSerialization.deserializeFromXml(xmlContent, ims.rules.helper.Entities.getInstance());							
						rules.add(rule);
					} 
					catch (Exception e) 
					{
						// Nothing else to do so far, I will throw a runtime exception later...
						e.printStackTrace();
					} 
				}
			}
		}		
		
		IRule[] collection = new IRule[rules.size()];
		rules.toArray(collection);
		return collection;						
	}
			
	return null;	
}
 
Example 39
Project: openMAXIMS   File: UserRulesProvider.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public IRule[] getUserRules() 
{				
	DomainFactory factory = getDomainFactory();
	StringBuffer hql = new StringBuffer(" from BusinessRule br where br.active = 1");
	List lst = factory.find(hql.toString());
	 
	if (lst != null)
	{
		List<IRule> rules = new ArrayList<IRule>();
		
		Iterator<Object> i = lst.iterator();
		
		while(i.hasNext())
		{
			BusinessRule dbRule = (BusinessRule)i.next();
			
			if (dbRule != null)
			{
				String xmlContent = dbRule.getXmlContent();
				if (xmlContent != null)
				{
					IRule rule;
					try 
					{
						rule = RuleXmlSerialization.deserializeFromXml(xmlContent, ims.rules.helper.Entities.getInstance());							
						rules.add(rule);
					} 
					catch (Exception e) 
					{
						// Nothing else to do so far, I will throw a runtime exception later...
						e.printStackTrace();
					} 
				}
			}
		}		
		
		IRule[] collection = new IRule[rules.size()];
		rules.toArray(collection);
		return collection;						
	}
			
	return null;	
}
 
Example 40
Project: openmaxims-linux   File: Logic.java   Source Code and License 4 votes vote down vote up
private IRule getRuleFromScreen()
{
	Rule rule = new Rule();

	rule.setName(form.lyrRules().tabGeneral().txtName().getValue());
	rule.setDescription(form.lyrRules().tabGeneral().txtDescription().getValue());
	rule.setPriority(0);
	if (form.lyrRules().tabGeneral().chkDateRange().getValue())
	{
		rule.setValidFrom(form.lyrRules().tabGeneral().dteValidFrom().getValue());
		rule.setValidTo(form.lyrRules().tabGeneral().dteValidTo().getValue());
	}
	else
	{
		rule.setValidFrom(null);
		rule.setValidTo(null);
	}

	rule.setRootEntity(form.lyrRules().tabConditions().cmbRootEntity().getValue());

	List<IRuleCondition> conditions = new ArrayList<IRuleCondition>();
	List<IRuleCondition> valueConditions = new ArrayList<IRuleCondition>();

	int numberOfRows = form.lyrRules().tabConditions().dyngrdConditions().getRows().size();
	RuleLogicalCondition logicalCondition = null;
	RuleValueConditionEntry entry = null;

	for (int i = 0; i < numberOfRows; i++)
	{
		DynamicGridRow row = form.lyrRules().tabConditions().dyngrdConditions().getRows().get(i);
		RuleConditionRowVo rowIdentifier = (RuleConditionRowVo) row.getIdentifier();
		int numberOfColums = rowIdentifier.getNumberOfColumns();

		if (rowIdentifier != null)
		{
			logicalCondition = checkForLogicalCondition(logicalCondition, row, rowIdentifier, numberOfColums);
			if (row.getRows() != null)
			{
				entry = checkForChildValueCondition(valueConditions, entry, row);
			}
		}
	}

	if (entry == null)
		return null;

	logicalCondition.setConditions(valueConditions);
	conditions.add(logicalCondition);
	rule.setConditions(conditions);

	rule.setActions(getActions());

	return rule;
}
 
Example 41
Project: openmaxims-linux   File: Logic.java   Source Code and License 4 votes vote down vote up
private void renderLogicalCondition(StringBuilder sb, RuleLogicalCondition condition, IRule rule, int tabs)
{

	if (tabs == 0)
	{
		sb.append("<b>{</b><br>");
	}
	else
	{
		sb.append("<b><br>{</b>");
	}
	for (int x = 0; x < condition.getConditions().size(); x++)
	{
		if (x > 0)
		{
			if (condition.equals(RuleLogicalCondition.getInstance(RuleLogicalConditionType.ALLTRUE)))
			{
				sb.append("<b>  &&  </b> ");
				tabs = 1;
			}
			/*
			 * else if(condition.equals(RuleLogicalCondition.getInstance(
			 * RuleLogicalConditionType.ALLFALSE))) {
			 * sb.append("<b>  &&  </b> "); tabs=1; }
			 */
			else if (condition.equals(RuleLogicalCondition.getInstance(RuleLogicalConditionType.ONETRUE)))
			{
				sb.append("<b>  ||  </b> ");
				tabs = 1;
			}
			/*
			 * else if(condition.equals(RuleLogicalCondition.getInstance(
			 * RuleLogicalConditionType.ONEFALSE))) {
			 * sb.append("<b>  ||  </b> "); tabs=1; }
			 */
		}

		renderCondition(sb, condition.getConditions().get(x), rule, tabs);
	}
	sb.append("<b>}</b><br>");
}
 
Example 42
Project: openmaxims-linux   File: UserRulesProvider.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public IRule[] getUserRules() 
{				
	DomainFactory factory = getDomainFactory();
	StringBuffer hql = new StringBuffer(" from BusinessRule br where br.active = 1");
	List lst = factory.find(hql.toString());
	 
	if (lst != null)
	{
		List<IRule> rules = new ArrayList<IRule>();
		
		Iterator<Object> i = lst.iterator();
		
		while(i.hasNext())
		{
			BusinessRule dbRule = (BusinessRule)i.next();
			
			if (dbRule != null)
			{
				String xmlContent = dbRule.getXmlContent();
				if (xmlContent != null)
				{
					IRule rule;
					try 
					{
						rule = RuleXmlSerialization.deserializeFromXml(xmlContent, ims.rules.helper.Entities.getInstance());							
						rules.add(rule);
					} 
					catch (Exception e) 
					{
						// Nothing else to do so far, I will throw a runtime exception later...
						e.printStackTrace();
					} 
				}
			}
		}		
		
		IRule[] collection = new IRule[rules.size()];
		rules.toArray(collection);
		return collection;						
	}
			
	return null;	
}
 
Example 43
Project: openmaxims-linux   File: UserRulesProvider.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings("unchecked")
public IRule[] getUserRules() 
{				
	DomainFactory factory = getDomainFactory();
	StringBuffer hql = new StringBuffer(" from BusinessRule br where br.active = 1");
	List lst = factory.find(hql.toString());
	 
	if (lst != null)
	{
		List<IRule> rules = new ArrayList<IRule>();
		
		Iterator<Object> i = lst.iterator();
		
		while(i.hasNext())
		{
			BusinessRule dbRule = (BusinessRule)i.next();
			
			if (dbRule != null)
			{
				String xmlContent = dbRule.getXmlContent();
				if (xmlContent != null)
				{
					IRule rule;
					try 
					{
						rule = RuleXmlSerialization.deserializeFromXml(xmlContent, ims.rules.helper.Entities.getInstance());							
						rules.add(rule);
					} 
					catch (Exception e) 
					{
						// Nothing else to do so far, I will throw a runtime exception later...
						e.printStackTrace();
					} 
				}
			}
		}		
		
		IRule[] collection = new IRule[rules.size()];
		rules.toArray(collection);
		return collection;						
	}
			
	return null;	
}