本文整理汇总了Java中net.ssehub.easy.varModel.model.ModelQueryException类的典型用法代码示例。如果您正苦于以下问题:Java ModelQueryException类的具体用法?Java ModelQueryException怎么用?Java ModelQueryException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModelQueryException类属于net.ssehub.easy.varModel.model包,在下文中一共展示了ModelQueryException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: determineFrozenStatePath
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Determines a frozen state path.
*
* @param var the variable to determine the path for
* @param mapping the runtime variable mapping
* @return the frozen state path
*/
public static List<String> determineFrozenStatePath(IDecisionVariable var, RuntimeVariableMapping mapping) {
// if possible, follow paths up (in particular pipeline)
IDecisionVariable top = Configuration.getTopLevelDecision(var);
List<String> path = new ArrayList<String>();
appendName(path, top);
IDecisionVariable pipElt = mapping.getReferencedBy(top);
if (null == pipElt) { // detailed: null != pipElt -> appendName(path, pipElt);
pipElt = top;
}
try {
IDecisionVariable pipeline = PipelineHelper.obtainPipeline(var.getConfiguration(), pipElt);
if (null != pipeline) {
appendName(path, pipeline);
// -> element in pipeline
}
} catch (ModelQueryException e) {
}
return path;
}
示例2: getAlgorithmParameters
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
@Override
public Map<String, List<AlgorithmParameter>> getAlgorithmParameters() {
if (null == parameter) {
Models models = RepositoryConnector.getModels(Phase.MONITORING);
if (null == config && null != models) {
models.startUsing();
config = models.getConfiguration();
if (null != config) {
Project prj = config.getProject();
try {
// ok as long as the model is not changing - then clear variables...
algorithms = ModelQuery.findVariable(prj, "algorithms", null);
} catch (ModelQueryException e) {
LogManager.getLogger(Tracing.class).error("cannot find 'algorithms'", e);
}
}
models.endUsing();
}
if (null != config && null != algorithms) {
parameter = collectAlgorithmParameters(config, algorithms);
}
}
return parameter;
}
示例3: createViolationInstance
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
@Override
protected ViolatingClause createViolationInstance(IDecisionVariable var, String operation, Double deviation,
Double deviationPercentage) {
ViolatingClause clause = null;
ActualViolation act = isActualViolation(var, operation, deviation);
if (null != act) {
clause = new ViolatingClause(act.observable, Configuration.getInstanceName(act.variable, true),
operation, deviation, deviationPercentage);
try {
IDecisionVariable pVar = PipelineHelper.obtainPipeline(config, act.variable);
if (null != pVar) {
Value pValue = pVar.getValue();
if (pValue instanceof CompoundValue) {
Value nValue = ((CompoundValue) pValue).getNestedValue(QmConstants.SLOT_NAME);
if (nValue instanceof StringValue) {
clause.setPipeline(((StringValue) nValue).getValue());
}
}
}
} catch (ModelQueryException e) {
}
}
return clause;
}
示例4: reloadIvml
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Forces that IVML-related models are reloaded. Call {@link #startUsing()} before.
*/
public void reloadIvml() {
VarModel.INSTANCE.outdateAll();
if (null != configuration) {
Project oldProject = configuration.getProject();
Project newProject = VarModel.INSTANCE.reload(oldProject, true);
if (oldProject == newProject) {
LogManager.getLogger(RepositoryConnector.class).error("IVML model " + oldProject.getName()
+ " was not reloaded.");
}
configuration = createConfiguration(newProject, phase);
try {
variableMapping = ConfigurationInitializer.createVariableMapping(configuration);
} catch (ModelQueryException e) {
LogManager.getLogger(RepositoryConnector.class).error(e.getMessage(), e);
}
}
}
示例5: createVariableMapping
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Creates a runtime variable mapping for <code>configuration</code>.
*
* @param config the configuration
* @return the runtime variable mapping
* @throws ModelQueryException in case of problems accessing model elements
*/
@Invisible
public static RuntimeVariableMapping createVariableMapping(
net.ssehub.easy.varModel.confModel.Configuration config) throws ModelQueryException {
Project project = config.getProject();
Compound sourceType = findCompound(project, TYPE_SOURCE);
Compound familyElementType = findCompound(project, TYPE_FAMILYELEMENT);
Compound sinkType = findCompound(project, TYPE_SINK);
RuntimeVariableMapping result = new RuntimeVariableMapping();
Iterator<IDecisionVariable> iter = config.iterator();
while (iter.hasNext()) {
IDecisionVariable var = iter.next();
IDatatype type = var.getDeclaration().getType();
if (sourceType.isAssignableFrom(type) || sinkType.isAssignableFrom(type)
|| familyElementType.isAssignableFrom(type)) {
addVariableMapping(var, SLOT_AVAILABLE, result);
}
}
return result;
}
示例6: setPipelines
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的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;
}
示例7: obtainPipeline
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Returns the pipeline decision for the given pipeline <code>element</code>.
*
* @param configuration the configuration for the lookup
* @param element the pipeline element (may be <b>null</b>, leads to <b>null</b>)
* @return the pipeline, may be <b>null</b> if the pipeline was not found
* @throws ModelQueryException if accessing type information fails
*/
@Invisible
public static IDecisionVariable obtainPipeline(net.ssehub.easy.varModel.confModel.Configuration configuration,
IDecisionVariable element) throws ModelQueryException {
IDecisionVariable result = null;
if (null != element) {
AbstractVariable elementDecl = element.getDeclaration();
IDatatype elementType = elementDecl.getType();
IModelElement par = elementDecl.getTopLevelParent();
if (par instanceof Project) {
Project prj = (Project) par;
IDatatype pipelineElementType = ModelQuery.findType(prj, QmConstants.TYPE_PIPELINE_ELEMENT, null);
if (null != pipelineElementType && pipelineElementType.isAssignableFrom(elementType)) {
IDatatype pipelineType = ModelQuery.findType(prj, QmConstants.TYPE_PIPELINE, null);
if (null != pipelineType) {
result = searchScope(configuration, prj, pipelineType);
}
}
}
}
return result;
}
示例8: obtainPipelineByName
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Returns a pipeline from the configuration from a given variable containing pipelines.
*
* @param config the configuration
* @param name the name of the pipeline
* @param varName the variable containing the pipelines
* @return the pipeline or <b>null</b> if it does not exist
*/
@QMInternal
public static IDecisionVariable obtainPipelineByName(net.ssehub.easy.varModel.confModel.Configuration config,
String name, String varName) {
IDecisionVariable result = null;
try {
AbstractVariable pips = ModelQuery.findVariable(config.getProject(), varName, null);
IDecisionVariable pipsVar = config.getDecision(pips);
if (null != pipsVar) {
for (int n = 0; null == result && n < pipsVar.getNestedElementsCount(); n++) {
IDecisionVariable pip = net.ssehub.easy.varModel.confModel.Configuration.dereference(
pipsVar.getNestedElement(n));
if (VariableHelper.hasName(pip, name)) {
result = pip;
}
}
}
} catch (ModelQueryException e) {
// -> result = null
}
return result;
}
示例9: isHardwareAlgorithm
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Returns whether <code>var</code> is a hardware algorithm.
*
* @param var the variable to check
* @return <code>true</code> for hardware algorithm, <code>false</code> else
*/
@QMInternal
public static boolean isHardwareAlgorithm(IDecisionVariable var) {
boolean result = false;
if (null != var) {
try {
IDatatype hwAlgType = ModelQuery.findType(var.getConfiguration().getProject(),
QmConstants.TYPE_HARDWARE_ALGORITHM, null);
if (null != hwAlgType) {
result = hwAlgType.isAssignableFrom(var.getDeclaration().getType());
}
} catch (ModelQueryException e) {
// -> result = null
}
}
return result;
}
示例10: obtainAlgorithmByName
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Obtains an algorithm from <code>config</code> by its name.
*
* @param config the configuration
* @param name the name of the algorithm
* @return the algorithm or <b>null</b> if not found
*/
@QMInternal
public static IDecisionVariable obtainAlgorithmByName(net.ssehub.easy.varModel.confModel.Configuration config,
String name) {
IDecisionVariable result = null;
try {
AbstractVariable algVarDecl = ModelQuery.findVariable(
config.getProject(), QmConstants.VAR_ALGORITHMS_ALGORITHMS, null);
if (null != algVarDecl) {
IDecisionVariable algs = config.getDecision(algVarDecl);
if (null != algs) {
for (int n = 0; null == result && n < algs.getNestedElementsCount(); n++) {
IDecisionVariable nested = net.ssehub.easy.varModel.confModel.Configuration.dereference(
algs.getNestedElement(n));
if (VariableHelper.hasName(nested, name)) {
result = nested;
}
}
}
}
} catch (ModelQueryException e) {
// -> result = null
}
return result;
}
示例11: createFreezeBlock
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的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;
}
示例12: testReferences3
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Tests a single reference assignment (contributed by QualiMaster).
*
* @throws IOException should not occur
* @throws ModelQueryException should not occur
*/
@Test
public void testReferences3() throws IOException, ModelQueryException {
final String name = "references3";
File modelFile = createFile(name);
Configuration cfg = getIvmlConfiguration("QM8", NoVariableFilter.INSTANCE);
Map<String, Object> param = createParameterMap(null, null, cfg);
EqualitySetup<Script> setup = new EqualitySetup<Script>(modelFile, name, null, createTraceFile(name), param);
setup.setEnableEquals(false);
assertEqual(setup);
net.ssehub.easy.varModel.confModel.Configuration c = cfg.getConfiguration();
AbstractVariable var = ModelQuery.findVariable(c.getProject(), "hAlg", null);
Assert.assertNotNull(var);
IDecisionVariable d = c.getDecision(var);
IDecisionVariable a = d.getNestedElement("actualHwNode");
Assert.assertNotEquals(NullValue.INSTANCE, a.getValue());
}
示例13: testDispatch2
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Tests dynamic dispatch over references. Testing also {@link VariableValueCopier}.
*
* @throws IOException should not occur
* @throws ModelQueryException should not occur
* @throws CSTSemanticException should not occur
* @throws ValueDoesNotMatchTypeException should not occur
* @throws ConfigurationException should not occur
*/
@Test
public void testDispatch2() throws IOException, ModelQueryException, CSTSemanticException,
ValueDoesNotMatchTypeException, ConfigurationException {
final String name = "dispatch2";
net.ssehub.easy.varModel.confModel.Configuration cfg
= getIvmlConfiguration("dispatch2", NoVariableFilter.INSTANCE).getConfiguration();
Compound algType = (Compound) ModelQuery.findType(cfg.getProject(), "Algorithm", null);
CopySpec spec = new CopySpec(algType, "ref", "avail");
VariableValueCopier copier = new VariableValueCopier("TEST", spec);
copier.process(cfg);
Map<String, Object> param = createParameterMap(null, null, new Configuration(cfg, NoVariableFilter.INSTANCE));
EqualitySetup<Script> setup = new EqualitySetup<Script>(createFile(name), name, null,
createTraceFile(name), param);
assertEqual(setup);
}
示例14: findVariable
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Searches for a specified variable.
*
* @param name the name of the variable to search for (may be qualified)
* @param type the specific variable of datatype to be returned,
* {@link AbstractVariable} is used if <b>null</b>
* @return the corresponding variable or <b>null</b>
* @throws ModelQueryException
* in case of semantic problems
*/
public AbstractVariable findVariable(String name,
Class<? extends AbstractVariable> type) throws ModelQueryException {
ModelQueryException ex = null;
AbstractVariable result = null;
// search contexts first, from newest to oldest
for (int c = directContext.size() - 1; null == result && c >= 0; c--) {
try {
result = ModelQuery.findVariable(directContext.get(c), name, type);
} catch (ModelQueryException e) {
ex = e;
}
}
if (null == result) {
// last resort - ask the project, but not all variables are allowed/accessible...
result = ModelQuery.findVariable(project, name, type);
if (null != result && name.indexOf(IvmlKeyWords.NAMESPACE_SEPARATOR) < 0
&& !(findActualParent(result) instanceof Project)) {
result = null; // avoid erroneous compound access, exclude qualified access may
}
}
if (null == result && ex != null) {
throw ex;
}
return result;
}
示例15: findCompounds
import net.ssehub.easy.varModel.model.ModelQueryException; //导入依赖的package包/类
/**
* Finds compounds according to the given <code>names</code>.
*
* @param names the names of the compounds
* @param nullOnFail if <b>null</b> shall be returned on failing resolution
* @return the found compounds (<b>null</b> if there was nothing to resolve or
* individuals were not resolved and <code>nullOnFail</code>,
* else an array with <b>null</b> entries)
* @throws ModelQueryException in case of semantic problems
*/
public Compound[] findCompounds(List<String> names, boolean nullOnFail) throws ModelQueryException {
Compound[] result;
if (null == names || names.isEmpty()) {
result = null;
} else {
result = new Compound[names.size()];
for (int n = 0; null != result && n < names.size(); n++) {
result[n] = (Compound) findType(names.get(n), Compound.class);
if (nullOnFail && null == result[n]) {
result = null;
}
}
}
return result;
}