*/
public static TCGDisjunctiveNormalForm createDisjunctiveNormalForm(
TCGOCLExpression in_oExpression,
boolean in_bSplitInequations) {
TCGDisjunctiveNormalForm oDNF = GeneratedFactory.eINSTANCE
.createTCGDisjunctiveNormalForm();
if (in_oExpression == null)
return oDNF;
if (in_oExpression instanceof TCGOCLOperation) {
TCGOCLOperation oOpExp = (TCGOCLOperation) in_oExpression;
// TODO f�r alle andere booleschen Operatoren erweitern
if (oOpExp.getOperationName().compareTo("and") == 0) {
TCGDisjunctiveNormalForm oLeftDNF = createDisjunctiveNormalForm(oOpExp
.getLeft(), in_bSplitInequations);
TCGDisjunctiveNormalForm oRightDNF = createDisjunctiveNormalForm(oOpExp
.getRight(), in_bSplitInequations);
return connectTwoDNFWithAnd(oLeftDNF, oRightDNF);
}
if (oOpExp.getOperationName().compareTo("or") == 0) {
// TCGDisjunctiveNormalForm oLeftDNF = createDisjunctiveNormalForm(oOpExp
// .getLeft(), in_bSplitInequations);
// TCGDisjunctiveNormalForm oRightDNF = createDisjunctiveNormalForm(oOpExp
// .getRight(), in_bSplitInequations);
// return connectTwoDNFWithOr(oLeftDNF, oRightDNF);
TCGDisjunctiveNormalForm oFirstDNF = null;
{
TCGOCLExpression oFirstExp =
TCGOCLExpressionHelperClass.copyExpression(oOpExp.getLeft());
TCGOCLExpression oSecondExp =
TCGOCLExpressionHelperClass.copyExpression(oOpExp.getRight());
oFirstDNF = connectTwoDNFWithAnd(
createDisjunctiveNormalForm(oFirstExp, in_bSplitInequations),
createDisjunctiveNormalForm(oSecondExp, in_bSplitInequations));
}
TCGDisjunctiveNormalForm oSecondDNF = null;
{
TCGOCLExpression oFirstExp =
TCGOCLExpressionHelperClass.copyExpression(oOpExp.getLeft());
oFirstExp = net.sf.parteg.base.testcasegraph.helperclasses.TCGOCLExpressionHelperClass.negateLogicalTCGOCLExpression(oFirstExp);
TCGOCLExpression oSecondExp =
TCGOCLExpressionHelperClass.copyExpression(oOpExp.getRight());
oSecondDNF = connectTwoDNFWithAnd(
createDisjunctiveNormalForm(oFirstExp, in_bSplitInequations),
createDisjunctiveNormalForm(oSecondExp, in_bSplitInequations));
}
TCGDisjunctiveNormalForm oThirdDNF = null;
{
TCGOCLExpression oFirstExp =
TCGOCLExpressionHelperClass.copyExpression(oOpExp.getLeft());
TCGOCLExpression oSecondExp =
TCGOCLExpressionHelperClass.copyExpression(oOpExp.getRight());
oSecondExp = net.sf.parteg.base.testcasegraph.helperclasses.TCGOCLExpressionHelperClass.negateLogicalTCGOCLExpression(oSecondExp);
oThirdDNF = connectTwoDNFWithAnd(
createDisjunctiveNormalForm(oFirstExp, in_bSplitInequations),
createDisjunctiveNormalForm(oSecondExp, in_bSplitInequations));
}
return connectTwoDNFWithOr(oFirstDNF,
connectTwoDNFWithOr(oSecondDNF, oThirdDNF));
}
if (oOpExp.getOperationName().compareTo("not") == 0) {
// negation has to be applicated to all sub-expressions
// TODO: introduce unary operation - which side holds the
// information?
TCGOCLExpression oNegatedExpression = null;
if (oOpExp.getLeft() != null) {
oNegatedExpression = oOpExp.getLeft();
} else if (oOpExp.getRight() != null) {
oNegatedExpression = oOpExp.getRight();
}
if(TCGOCLExpressionHelperClass.isBooleanAtom(oNegatedExpression)) {
oDNF.getConjunctions().add(
GeneratedFactory.eINSTANCE.createTCGConjunction());
oDNF.getConjunctions().get(0).getExpressions().add(
TCGOCLExpressionHelperClass.copyExpression(in_oExpression));
return oDNF;
}
else {
// oOpExp.setLeft(negateTCGOCLExpression(oNegatedExpression));
// return createDisjunctiveNormalForm(oOpExp.getLeft(), in_bSplitInequations);
oNegatedExpression = net.sf.parteg.base.testcasegraph.helperclasses.TCGOCLExpressionHelperClass.negateLogicalTCGOCLExpression(oNegatedExpression);
return createDisjunctiveNormalForm(oNegatedExpression, in_bSplitInequations);
}
}
// split equations only if necessary
if(in_bSplitInequations == true)
{
// operation name = "<>"
TCGDisjunctiveNormalForm oNewDNF = TCGOCLExpressionHelperClass.splitUpInequationToDNF(oOpExp);
if(oNewDNF != null)
return oNewDNF;
}
/*
* if(oOpExp.getOperationName().compareTo("not removed") == 0) {
* if(oOpExp.getLeft() != null) { return
* createDisjunctiveNormalForm(oOpExp.getLeft()); } else
* if(oOpExp.getRight() != null) { return
* createDisjunctiveNormalForm(oOpExp.getRight()); } }
*/
} else if (in_oExpression instanceof TCGOCLIfThenElse) {
TCGOCLIfThenElse oTCGIfThenElse = (TCGOCLIfThenElse) in_oExpression;
// condition satisfied
TCGDisjunctiveNormalForm oConditionDNF = createDisjunctiveNormalForm(oTCGIfThenElse
.getCondition(), in_bSplitInequations);
TCGDisjunctiveNormalForm oThenDNF = createDisjunctiveNormalForm(oTCGIfThenElse
.getThenExpression(), in_bSplitInequations);
TCGDisjunctiveNormalForm oSatisfiedDNF = connectTwoDNFWithAnd(
oConditionDNF, oThenDNF);
// condition violated
oTCGIfThenElse.setCondition(net.sf.parteg.base.testcasegraph.helperclasses.TCGOCLExpressionHelperClass.negateLogicalTCGOCLExpression(oTCGIfThenElse.getCondition()));
TCGDisjunctiveNormalForm oNotConditionDNF = createDisjunctiveNormalForm(oTCGIfThenElse
.getCondition(), in_bSplitInequations);
TCGDisjunctiveNormalForm oElseDNF = createDisjunctiveNormalForm(oTCGIfThenElse
.getElseExpression(), in_bSplitInequations);
TCGDisjunctiveNormalForm oViolatedDNF = connectTwoDNFWithAnd(
oNotConditionDNF, oElseDNF);
return connectTwoDNFWithOr(oSatisfiedDNF, oViolatedDNF);
}