本文整理汇总了Java中net.ssehub.easy.varModel.cst.OCLFeatureCall类的典型用法代码示例。如果您正苦于以下问题:Java OCLFeatureCall类的具体用法?Java OCLFeatureCall怎么用?Java OCLFeatureCall使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OCLFeatureCall类属于net.ssehub.easy.varModel.cst包,在下文中一共展示了OCLFeatureCall类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAssignmentConstraint
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
@Override
protected ConstraintSyntaxTree createAssignmentConstraint(Project dstProject, AbstractVariable decl,
IDecisionVariable var, Value value) {
Configuration config = var.getConfiguration();
AbstractVariable dstDecl = null != varMapping ? varMapping.get(decl) : decl;
if (null == dstDecl) {
dstDecl = decl;
}
// do some referential integrity ;)
ConstraintSyntaxTree rightSide = null;
if (Reference.TYPE.isAssignableFrom(value.getType())) {
// search for sequence in imported models
rightSide = searchSequenceValue(dstProject, value, config);
}
if (null == rightSide) {
// fallback
rightSide = new ConstantValue(toSaveableValue(var, value));
}
ConstraintSyntaxTree constraint = new OCLFeatureCall(deriveOperand(dstDecl, var),
OclKeyWords.ASSIGNMENT, rightSide);
// CopyVisitor vis = new CopyVisitor(varMapping);
// constraint.accept(vis);
// return vis.getResult();
return constraint;
}
示例2: addTopLevelValues
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
* Adds top level values configured for <code>source</code> to <code>target</code>.
*
* @param cfg the actual configuration holding the values
* @param source the source project
* @param target the target project
* @param exclude the variable names to exclude
* @return the changed top-level variables ready for freezing
* @throws CSTSemanticException in case of CST errors
*/
private static List<IFreezable> addTopLevelValues(Configuration cfg, Project source, Project target,
String... exclude) throws CSTSemanticException {
List<IFreezable> result = new ArrayList<IFreezable>();
for (int e = 0; e < source.getElementCount(); e++) {
ContainableModelElement elt = source.getElement(e);
if (elt instanceof DecisionVariableDeclaration) {
DecisionVariableDeclaration decl = (DecisionVariableDeclaration) elt;
if (!Arrays.contains(exclude, decl.getName())) {
IDecisionVariable decVar = cfg.getDecision(decl);
Value value = decVar.getValue();
if (null != value && !ConstraintType.isConstraint(decVar.getDeclaration().getType())) {
ConstraintSyntaxTree cst = new OCLFeatureCall(new Variable(decl), IvmlKeyWords.ASSIGNMENT,
new ConstantValue(decVar.getValue().clone()));
cst.inferDatatype();
Constraint constraint = new Constraint(cst, target);
target.addConstraint(constraint);
result.add(decl);
}
}
}
}
return result;
}
示例3: setPipelines
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
* Sets the given <code>pipeline</code> as value in the <code>varName</code> of <code>prj</code>.
*
* @param prj the project to modify
* @param varName the variable to modify
* @param pipeline the pipeline to set as (reference) value
* @return the affected variable
* @throws ModelQueryException if access to the variable failed
* @throws CSTSemanticException in case of CST errors
* @throws ValueDoesNotMatchTypeException if <code>pipeline</code> does not match as a value
*/
private static DecisionVariableDeclaration setPipelines(Project prj, String varName,
DecisionVariableDeclaration pipeline) throws ModelQueryException, CSTSemanticException,
ValueDoesNotMatchTypeException {
DecisionVariableDeclaration pipelinesVar = (DecisionVariableDeclaration) ModelQuery.findVariable(prj,
varName, DecisionVariableDeclaration.class);
if (null != pipelinesVar && pipelinesVar.getType() instanceof Container) {
Container cType = (Container) pipelinesVar.getType();
ConstraintSyntaxTree cst = new OCLFeatureCall(new Variable(pipelinesVar), IvmlKeyWords.ASSIGNMENT,
new ConstantValue(ValueFactory.createValue(cType, pipeline)));
cst.inferDatatype();
Constraint constraint = new Constraint(cst, prj);
prj.addConstraint(constraint);
} else {
throw new ModelQueryException("pipelines variable '" + varName + "' not found",
ModelQueryException.ACCESS_ERROR);
}
return pipelinesVar;
}
示例4: createFreezeBlock
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
* Creates a freeze block for project. [legacy style, does not add to project]
*
* @param freezables
* the freezables
* @param project
* the IVML project to add to (may be <b>null</b> if failed)
* @param fallbackForType
* in case that <code>project</code> is being written the first time, may be <b>null</b>
* @return the created freeze block
* @throws CSTSemanticException
* in case of CST errors
* @throws ValueDoesNotMatchTypeException
* in case of unmatching values
* @throws ModelQueryException
* in case of model access problems
*/
public static FreezeBlock createFreezeBlock(IFreezable[] freezables, Project project, Project fallbackForType)
throws CSTSemanticException, ValueDoesNotMatchTypeException, ModelQueryException {
FreezeBlock result = null;
FreezeVariableType iterType = new FreezeVariableType(freezables, project);
DecisionVariableDeclaration iter = new DecisionVariableDeclaration("f", iterType, project);
net.ssehub.easy.varModel.model.datatypes.Enum type = ModelQuery.findEnum(project, TYPE_BINDING_TIME);
if (null == type && null != fallbackForType) {
type = ModelQuery.findEnum(fallbackForType, TYPE_BINDING_TIME);
}
String butOperation = "==";
EnumLiteral literal = type.get(CONST_BINDING_TIME_RUNTIME);
if (null == literal) { // newer version of the model
literal = type.get(CONST_BINDING_TIME_RUNTIME_MON);
butOperation = ">=";
}
ConstraintSyntaxTree runtime = new ConstantValue(ValueFactory.createValue(type, literal));
Variable iterEx = new AttributeVariable(new Variable(iter), iterType.getAttribute(ANNOTATION_BINDING_TIME));
OCLFeatureCall op = new OCLFeatureCall(iterEx, butOperation, runtime);
op.inferDatatype();
result = new FreezeBlock(freezables, iter, op, project);
return result;
}
示例5: visitOclFeatureCall
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
@Override
public void visitOclFeatureCall(OCLFeatureCall call) {
if (null != call.getOperand()) {
// user def function returns operand null!
if ((call.getOperand() instanceof Variable
|| call.getOperand() instanceof CompoundAccess)
&& call.getParameterCount() == 1
&& call.getOperation().equals(OclKeyWords.ASSIGNMENT)) {
if (call.getParameter(0) instanceof ConstantValue
|| call.getParameter(0) instanceof ContainerInitializer
|| call.getParameter(0) instanceof CompoundInitializer) {
isSimpleAssignment = true;
}
}
call.getOperand().accept(this);
for (int i = 0; i < call.getParameterCount(); i++) {
call.getParameter(i).accept(this);
}
}
}
示例6: processModificationForVariable
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
* Process modification rules, where operand is a variable.
* @param call OCL Call.
* @param constraintRule A string representation of Drools "not" of this this call.
*/
private void processModificationForVariable(OCLFeatureCall call,
String constraintRule) {
Variable var = (Variable) call.getOperand();
String name = ((Variable) call.getOperand()).getVariable().getName();
assgnConstraintsCalls(call);
addAssinmentConstraintsToMap(constraintRule, name);
configuredByDefaultList.add(name);
boolean varIsContainer = var.getVariable().getType().getTypeClass().equals(Sequence.class)
|| var.getVariable().getType().getTypeClass().equals(Set.class);
// boolean varIsCompound = var.getVariable().getType().getTypeClass().equals(Compound.class);
if (!varIsContainer ) {
logger.info("");
}
}
示例7: testSequenceProject
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
*Method to test the operation Isempty on seq.
*
*
* @throws ValueDoesNotMatchTypeException Should not occur
* if the values are configured correctly in relation to the datatype.
* @throws CSTSemanticException Must not occur, otherwise
* there is an error inside the CST package
*
*/
// @Test
public void testSequenceProject() throws CSTSemanticException, ValueDoesNotMatchTypeException {
Project project = new Project("testSequenceProject");
DecisionVariableDeclaration seqDec = new DecisionVariableDeclaration("seq_var", Sequence.TYPE, project);
Configuration conf = new Configuration(project);
project.add(seqDec);
DecisionVariableDeclaration boolA = new DecisionVariableDeclaration("boolA", BooleanType.TYPE, project);
project.add(boolA);
Variable var1 = new Variable(seqDec);
Variable var2 = new Variable(boolA);
OCLFeatureCall ocl1 = new OCLFeatureCall(var1, OclKeyWords.IS_EMPTY);
OCLFeatureCall ocl2 = new OCLFeatureCall(var2, OclKeyWords.EQUALS, ocl1);
Constraint cons1 = new Constraint(ocl2, null);
project.add(cons1);
engine = new DroolsReasoner();
ReasoningResult r = engine.check(project, conf, null, null);
Assert.assertFalse(r.hasConflict());
System.out.println(" .. has conflict?");
}
示例8: visitOclFeatureCall
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
@Override
public void visitOclFeatureCall(OCLFeatureCall call) {
this.innerlogic += "( ";
String op = call.getOperation();
if (DroolsOperations.isImplicitOperation(op)) {
call.getOperand().accept(this);
this.innerlogic += " " + DroolsOperations.getDroolsOperation(op) + " ";
call.getParameter(0).accept(this);
} else {
innerlogic += op;
innerlogic += "(";
call.getOperand().accept(this);
innerlogic += " , ";
call.getParameter(0).accept(this);
innerlogic += ")";
}
innerlogic += ")";
}
示例9: testSimpleConstraintCopy
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
* Copies a constraint, which has no outstanding dependencies.
* @throws ValueDoesNotMatchTypeException If String values cannot be created.
* @throws CSTSemanticException If a string constraint cannot be created
*/
@Test
public void testSimpleConstraintCopy() throws ValueDoesNotMatchTypeException, CSTSemanticException {
Project original = new Project("testSimpleConstraintCopy");
IDatatype basisType = StringType.TYPE;
DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", basisType, original);
original.add(decl);
Constraint constraint = new Constraint(original);
ConstantValue helloWorldVal = new ConstantValue(ValueFactory.createValue(basisType, "Hello World"));
OCLFeatureCall equality = new OCLFeatureCall(new Variable(decl), OclKeyWords.EQUALS, helloWorldVal);
constraint.setConsSyntax(equality);
original.add(constraint);
java.util.Set<Project> copiedProjects = new HashSet<Project>();
Project copy = copyProject(original, copiedProjects);
Constraint copiedConstraint = (Constraint) copy.getElement(1);
assertConstraint(constraint, copiedConstraint, copy, copiedProjects);
}
示例10: visitOclFeatureCall
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
@Override
public void visitOclFeatureCall(OCLFeatureCall call) {
boolean operationIsEquals = (call.getOperation().equals(OclKeyWords.EQUALS));
boolean operationIsImplies = call.getOperation().equals(OclKeyWords.IMPLIES);
if (operationIsEquals) {
if ((call.getOperand() instanceof Variable) || (call.getOperand() instanceof CompoundAccess)) {
// logger.info("This constraint needs to be there.");
acceptConstraint = true;
}
} else if (operationIsImplies) {
if (call.getParameter(0).getClass().equals(call.getClass())) {
OCLFeatureCall temp = (OCLFeatureCall) call.getParameter(0);
if (temp.getOperation().equals(OclKeyWords.EQUALS)) {
// logger.info("this should also be included.");
acceptConstraint = true;
}
} else if (call.getParameter(0) instanceof Parenthesis) {
OCLFeatureCall temp2 = new OCLFeatureCall(call.getOperand(), OclKeyWords.IMPLIES,
((Parenthesis) call.getParameter(0)).getExpr());
temp2.accept(this);
}
}
}
示例11: testCopyDerivedType
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
* Tests whether a simple {@link DerivedDatatype} without any dependencies can be copied.
* @throws CSTSemanticException If <tt>true</tt> cannot be created as constraint for a boolean type
*/
@Test
public void testCopyDerivedType() throws CSTSemanticException {
Project original = new Project("testCopyDerivedType");
IDatatype basisType = BooleanType.TYPE;
DerivedDatatype dType = new DerivedDatatype("posType", basisType, original);
Constraint constraint = new Constraint(dType);
OCLFeatureCall equality = new OCLFeatureCall(new Variable(dType.getTypeDeclaration()), OclKeyWords.EQUALS,
new ConstantValue(BooleanValue.TRUE));
constraint.setConsSyntax(equality);
dType.setConstraints(new Constraint[] {constraint});
original.add(dType);
java.util.Set<Project> copiedProjects = new HashSet<Project>();
Project copy = copyProject(original, copiedProjects);
DerivedDatatype copiedType = (DerivedDatatype) copy.getElement(0);
assertDerivedType(dType, copiedType, copy, copiedProjects);
}
示例12: testOperationDependingCSTCopy
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
* Tests whether a {@link OperationDefinition}, with a depending CST could be copied.
*/
@Test
public void testOperationDependingCSTCopy() {
Project original = new Project("testOperationDependingCSTCopy");
DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", RealType.TYPE, original);
OperationDefinition operation = new OperationDefinition(original);
ExplicitTypeVariableDeclaration parameterDecl = new ExplicitTypeVariableDeclaration("param1", RealType.TYPE,
operation);
OCLFeatureCall comparison = new OCLFeatureCall(new Variable(parameterDecl), OclKeyWords.GREATER,
new Variable(decl));
CustomOperation func = new CustomOperation(BooleanType.TYPE, "returnsTrue", original.getType(), comparison,
new DecisionVariableDeclaration[] {parameterDecl});
operation.setOperation(func);
original.add(operation);
original.add(decl);
Project copy = copyProject(original);
OperationDefinition copiedOp = (OperationDefinition) copy.getElement(1);
assertUserOperation(operation, copiedOp, copy);
}
示例13: testDependingPartialEvaluationCopy
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
* Tests a copying of an evaluation block depending on a declaration defined at a later point.
* @throws CSTSemanticException If {@link Constraint#setConsSyntax(ConstraintSyntaxTree)} is not working.
*/
@Test
public void testDependingPartialEvaluationCopy() throws CSTSemanticException {
Project orgProject = new Project("testDependingPartialEvaluationCopy");
DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", BooleanType.TYPE, orgProject);
PartialEvaluationBlock evalBlock = new PartialEvaluationBlock("evalBlock", orgProject);
Constraint constraint = new Constraint(evalBlock);
OCLFeatureCall equality = new OCLFeatureCall(new Variable(decl), OclKeyWords.EQUALS,
new ConstantValue(BooleanValue.TRUE));
constraint.setConsSyntax(equality);
evalBlock.setEvaluables(new IPartialEvaluable[] {constraint});
orgProject.add(evalBlock);
orgProject.add(decl);
java.util.Set<Project> copiedProjects = new HashSet<Project>();
Project copiedProject = copyProject(orgProject, copiedProjects);
PartialEvaluationBlock copiedBlock = (PartialEvaluationBlock) copiedProject.getElement(0);
assertEvalBlock(evalBlock, copiedBlock, copiedProject, copiedProjects);
}
示例14: testPartialEvaluationCopyWithInternallyDeclaredVariable
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
* Tests a copying of an evaluation block containing a constraining, which uses a
* {@link DecisionVariableDeclaration} declared inside of the block.
* @throws CSTSemanticException If {@link Constraint#setConsSyntax(ConstraintSyntaxTree)} is not working.
*/
@Test
public void testPartialEvaluationCopyWithInternallyDeclaredVariable() throws CSTSemanticException {
Project orgProject = new Project("testPartialEvaluationCopyWithInternallyDeclaredVariable");
PartialEvaluationBlock evalBlock = new PartialEvaluationBlock("evalBlock", orgProject);
DecisionVariableDeclaration decl = new DecisionVariableDeclaration("decl", BooleanType.TYPE, evalBlock);
Constraint constraint = new Constraint(evalBlock);
OCLFeatureCall equality = new OCLFeatureCall(new Variable(decl), OclKeyWords.EQUALS,
new ConstantValue(BooleanValue.TRUE));
constraint.setConsSyntax(equality);
evalBlock.setEvaluables(new IPartialEvaluable[] {constraint});
orgProject.add(evalBlock);
evalBlock.addModelElement(decl);
java.util.Set<Project> copiedProjects = new HashSet<Project>();
Project copiedProject = copyProject(orgProject, copiedProjects);
PartialEvaluationBlock copiedBlock = (PartialEvaluationBlock) copiedProject.getElement(0);
assertEvalBlock(evalBlock, copiedBlock, copiedProject, copiedProjects);
}
示例15: testCompoundOperation
import net.ssehub.easy.varModel.cst.OCLFeatureCall; //导入依赖的package包/类
/**
* Copies a compoundOperation and compares the return-types.
* @throws CSTSemanticException should not occur
*/
@Test
public void testCompoundOperation() throws CSTSemanticException {
for (int i = 0; i < Operation.getOperationsCount(); i++) {
Operation operation = Operation.getOperation(i);
Variable operand = map.get(operation.getOperand());
Variable[] parameters = new Variable[operation.getParameterCount()];
if (null != operand) {
if (Compound.TYPE == operand.inferDatatype()) {
for (int j = 0; j < operation.getParameterCount(); j++) {
parameters[j] = map.get(operation.getParameterType(j));
}
OCLFeatureCall call = new OCLFeatureCall(operand, operation.getName(), parameters);
Assert.assertEquals(operation.getReturns(), call.inferDatatype());
}
}
}
}