本文整理汇总了Java中net.ssehub.easy.varModel.model.Project.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Project.getName方法的具体用法?Java Project.getName怎么用?Java Project.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.ssehub.easy.varModel.model.Project
的用法示例。
在下文中一共展示了Project.getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isSavingEnabled
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override
protected boolean isSavingEnabled(Project destProject, IDecisionVariable var) {
// avoid that all imported config is saved over and over again
// role separation
boolean enabled;
AbstractVariable decl = var.getDeclaration();
IDatatype type = decl.getType();
// QualiMaster convention
if (ConstraintType.isConstraint(type)) {
enabled = false;
} else if (var.getParent() instanceof Configuration) {
String decisionNamespace = var.getDeclaration().getNameSpace();
String dstProjectNamespace = destProject.getName();
enabled = dstProjectNamespace.equals(decisionNamespace);
if (!enabled && dstProjectNamespace.endsWith(QmConstants.CFG_POSTFIX)) {
String defProjectNamespace = dstProjectNamespace.substring(0,
dstProjectNamespace.length() - QmConstants.CFG_POSTFIX.length());
enabled = defProjectNamespace.equals(decisionNamespace);
}
} else {
enabled = true;
}
return enabled;
}
示例2: validateConstraint
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Evaluates the specified constraint with the {@link EvaluationVisitor} and tests that the
* {@link EvaluationVisitor} creates the expected output.
* @param testProject The project which is used for testing.
* @param equalityCST The (un)equality constraint to evaluate.
* @param isValid <tt>true</tt> The {@link EvaluationVisitor} should <b>not</b> detect a violation,
* <tt>false</tt> the {@link EvaluationVisitor} should detect a violation.
*/
private void validateConstraint(Project testProject, ConstraintSyntaxTree equalityCST, boolean isValid) {
// Run evaluation visitor
Configuration config = new Configuration(testProject, true);
EvaluationVisitor evalVisitor = new EvaluationVisitor(config, null, false, null);
equalityCST.accept(evalVisitor);
// Test expected result
String cstAsString = "\"" + StringProvider.toIvmlString(equalityCST, testProject) + "\" in project \""
+ testProject.getName() + "\"";
if (isValid) {
Assert.assertFalse("Evaluation visitor should NOT detect errors on " + cstAsString + ", but it did.",
evalVisitor.constraintFailed());
Assert.assertTrue("Evaluation visitor should NOT detect violations on " + cstAsString + ", but it did.",
evalVisitor.constraintFulfilled());
} else {
Assert.assertTrue("Evaluation visitor should detect errors on " + cstAsString + ", but it did NOT.",
evalVisitor.constraintFailed());
Assert.assertFalse("Evaluation visitor should detect violations on " + cstAsString + ", "
+ "but it did NOT.", evalVisitor.constraintFulfilled());
}
}
示例3: visitProject
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
@Override
public void visitProject(Project project) {
abortReasoning = false;
String name = project.getName();
dPrinter = new DroolsPrinter();
if (evaluationChecking) {
name += "_eval";
}
(new DroolsDelegationVisitor()).addDroolsGlobals(name, dPrinter);
for (int i = 0; i < project.getElementCount(); i++) {
if (project.getElement(i) instanceof DecisionVariableDeclaration
&& ((DecisionVariableDeclaration) project.getElement(i)).getType() instanceof Compound) {
DecisionVariableDeclaration decl = (DecisionVariableDeclaration) project.getElement(i);
if (compMap2.containsKey(decl.getType().getName())) {
compMap2.get(decl.getType().getName()).add(decl.getName());
} else {
compMap2.put(decl.getType().getName(), new ArrayList<String>());
compMap2.get(decl.getType().getName()).add(decl.getName());
}
}
}
}
示例4: getBindingTimeAnnotation
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Returns the binding time annotation of the project to create the selector statement of the freeze block.
* @param project The project for which the freeze block shall be created.
* @return The binding time annotation or <tt>null</tt> it could not be found.
*/
private Attribute getBindingTimeAnnotation(Project project) {
Attribute btAnnotation = project.getAttribute(QmConstants.ANNOTATION_BINDING_TIME);
// Try to build up the cache
if (null == btAnnotation && project.getName().endsWith(QmConstants.CFG_POSTFIX)) {
String baseName = project.getName().substring(0, project.getName().length()
- QmConstants.CFG_POSTFIX.length());
Project baseProject = usedProjects.get(baseName);
if (null == baseProject) {
for (int i = 0, end = project.getImportsCount(); i < end && null == baseProject; i++) {
Project importedProject = project.getImport(i).getResolved();
String importedName = importedProject.getName();
if (!usedProjects.containsKey(importedName)) {
usedProjects.put(importedName, importedProject);
}
if (baseName.equals(importedName)) {
baseProject = importedProject;
}
}
}
if (null != baseProject) {
for (int i = 0, end = baseProject.getAttributesCount(); i < end && btAnnotation == null; i++) {
btAnnotation = baseProject.getAttribute(QmConstants.ANNOTATION_BINDING_TIME);
}
}
}
return btAnnotation;
}
示例5: saveProject
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Saves the given project to the specified folder.
* @param destFolder The folder where the project shall be saved to.
* @param project The project to be saved.
* @throws IOException if the file exists but is a directory rather than
* a regular file, does not exist but cannot be created,
* or cannot be opened for any other reason
*/
public static void saveProject(File destFolder, Project project) throws IOException {
try (FileWriter fWriter = new FileWriter(new File(destFolder, project.getName() + ".ivml"))) {
IVMLWriter iWriter = new IVMLWriter(fWriter);
project.accept(iWriter);
} catch (IOException ioe) {
throw ioe;
}
}
示例6: reasoningTest
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Method to test whether different types of variables and constraints could be translated correctly
* into rules and reasoned on without any errors.
* @param p0 IVML file to translate and reason on.
* @param p1 IVML file to translate and reason on.
* @param expectedFailedConstraints Number of constraints that are expected to fail.
*/
public void reasoningTest(String p0, String p1, int expectedFailedConstraints) {
Project projectP0 = loadProject(p0);
Project projectP1 = loadProject(p1);
ProjectImport importP0 = new ProjectImport(projectP0.getName(), null);
projectP1.addImport(importP0);
resultHandler(expectedFailedConstraints, projectP1);
}
示例7: getBindingTimeAnnotation
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Returns the binding time annotation of the project to create the selector statement of the freeze block.
* @param project The project for which the freeze block shall be created.
* @return The binding time annotation or <tt>null</tt> it could not be found.
*/
private Attribute getBindingTimeAnnotation(Project project) {
Attribute btAnnotation = project.getAttribute(ANNOTATION_BINDING_TIME);
// Try to build up the cache
if (null == btAnnotation && project.getName().endsWith(CFG_POSTFIX)) {
String baseName = project.getName().substring(0, project.getName().length() - CFG_POSTFIX.length());
Project baseProject = usedProjects.get(baseName);
if (null == baseProject) {
for (int i = 0, end = project.getImportsCount(); i < end && null == baseProject; i++) {
Project importedProject = project.getImport(i).getResolved();
String importedName = importedProject.getName();
if (!usedProjects.containsKey(importedName)) {
usedProjects.put(importedName, importedProject);
}
if (baseName.equals(importedName)) {
baseProject = importedProject;
}
}
}
if (null != baseProject) {
for (int i = 0, end = baseProject.getAttributesCount(); i < end && btAnnotation == null; i++) {
btAnnotation = baseProject.getAttribute(ANNOTATION_BINDING_TIME);
}
}
}
return btAnnotation;
}
示例8: testNonEmptyProjectImport
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests that a {@link ProjectImport} with a non empty project can be copied.
* The importing project has a declaration with a default value to the imported project.
* @throws ModelManagementException If {@link ProjectImport#setResolved(Project)} is not working
* @throws CSTSemanticException If {@link DecisionVariableDeclaration#setValue(ConstraintSyntaxTree)} is not working
* @throws ValueDoesNotMatchTypeException If {@link DecisionVariableDeclaration#setValue(ConstraintSyntaxTree)}
* is not working
*/
@Test
public void testNonEmptyProjectImport() throws ModelManagementException, ValueDoesNotMatchTypeException,
CSTSemanticException {
Project importedProject = new Project("importedProject_of_testNonEmptyProjectImport");
DecisionVariableDeclaration decl1 = new DecisionVariableDeclaration("importedDecl", IntegerType.TYPE,
importedProject);
importedProject.add(decl1);
Project mainProject = new Project("mainProject_of_testNonEmptyProjectImport");
ProjectImport pImport = new ProjectImport(importedProject.getName());
pImport.setResolved(importedProject);
mainProject.addImport(pImport);
DecisionVariableDeclaration decl2 = new DecisionVariableDeclaration("mainDecl", IntegerType.TYPE, mainProject);
Variable defltValue = new Variable(decl1);
decl2.setValue(defltValue);
mainProject.add(decl2);
Project copiedMain = copyProject(mainProject);
DecisionVariableDeclaration copiedDecl2 = (DecisionVariableDeclaration) copiedMain.getElement(0);
Project copiedImported = copiedMain.getImport(0).getResolved();
DecisionVariableDeclaration copiedDecl1 = (DecisionVariableDeclaration) copiedImported.getElement(0);
// Tuple (original declaration, expected copied parent)
Map<AbstractVariable, IModelElement> mapping = new HashMap<AbstractVariable, IModelElement>();
mapping.put(decl1, copiedImported);
mapping.put(decl2, copiedMain);
assertDeclaration(decl1, copiedDecl1, mapping);
assertDeclaration(decl2, copiedDecl2, mapping);
}
示例9: setUp
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Configures a project with two interfaces which is importing another project also with two interfaces.
*/
@Before
public void setUp() {
// Create imported project
Project importedProject = new Project("importedProject");
importedInterfaceUsed = new ProjectInterface("importedInterfaceUsed", null, importedProject);
importedInterfaceUnused = new ProjectInterface("importedInterfaceUnused", null, importedProject);
importedProject.add(importedInterfaceUsed);
importedProject.add(importedInterfaceUnused);
ProjectTestUtilities.validateProject(importedProject);
// Create importing project
project = new Project("mainProject");
ProjectImport pImport = new ProjectImport(importedProject.getName(), importedInterfaceUsed.getName());
try {
pImport.setResolved(importedProject);
} catch (ModelManagementException e) {
Assert.fail("Creation of project import failed: " + e.getMessage());
e.printStackTrace();
}
project.addImport(pImport);
ownInterface1 = new ProjectInterface("ownInterface1", null, project);
ownInterface2 = new ProjectInterface("ownInterface2", null, project);
project.add(ownInterface1);
project.add(ownInterface2);
ProjectTestUtilities.validateProject(project);
}
示例10: addImport
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Adds a {@link ProjectImport} to the {@link #basicProject}.
* @param importedProject one of {@link #cmpProject} or {@link #interfacedProject}.
*/
private void addImport(Project importedProject) {
String interfaceName = importedProject == interfacedProject ? INTERFACE_NAME : null;
ProjectImport pImport = new ProjectImport(importedProject.getName(), interfaceName);
try {
pImport.setResolved(importedProject);
} catch (ModelManagementException e) {
Assert.fail(e.getMessage());
}
basicProject.addImport(pImport);
}
示例11: setUp
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* SetUp method: creates an empty project together with a configuration.
* @throws URISyntaxException Must not occur
*/
@Before
public void setUp() throws URISyntaxException {
project = new Project("configurationTestProject");
// This call overwrites old instances of projects with same name and version number
URI fictiveLocation = new URI("path/" + project.getName());
VarModel.INSTANCE.updateModel(project, fictiveLocation);
// Configuration must be started with AssignmentResolver, since Reasoner is not available in this project.
configuration = new Configuration(project, true);
}
示例12: createIdenticalVariable
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Helping method of {@link #testWriteQualifiedNames()} for creating a variable in a new project.
* All variables should have the same name to check the usage of qualified names.
* @param projectName The name of the (imported) project to create.
* @return The {@link DecisionVariableDeclaration} of the newly created variable.
*/
private DecisionVariableDeclaration createIdenticalVariable(String projectName) {
Project predecessor = new Project(projectName);
DecisionVariableDeclaration var = new DecisionVariableDeclaration("variable", IntegerType.TYPE, predecessor);
predecessor.add(var);
ProjectImport imp = new ProjectImport(predecessor.getName(), null);
try {
imp.setResolved(predecessor);
} catch (ModelManagementException e) {
Assert.fail(e.getMessage());
}
pro.addImport(imp);
return var;
}
示例13: write
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Recursive method to save all rpoejcts and their imports.
* @param project The current project so save
* @throws IOException If an IO error occurs during saving one of the projects.
*/
private void write(Project project) throws IOException {
if (!done.contains(project)) {
done.add(project);
// Save project
FileWriter fWriter = null;
try {
File trgFile = new File(folder, project.getName() + ".ivml");
fWriter = new FileWriter(trgFile);
IVMLWriter iWriter = new IVMLWriter(fWriter);
iWriter.setFormatInitializer(formatInitializer);
iWriter.forceComponundTypes(forceCompoundTypes);
project.accept(iWriter);
iWriter.flush();
} finally {
if (null != fWriter) {
fWriter.close();
}
}
// Save imported projects
for (int i = 0, end = project.getImportsCount(); i < end; i++) {
Project importedProject = project.getImport(i).getResolved();
if (null != importedProject) {
write(importedProject);
}
}
}
}
示例14: testRemoveLinksToElementsOfRemovedImports
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests whether elements declared inside a removed import are also resolved correctly outside of the import.
* @throws ModelManagementException Must not occur,
* otherwise is the {@link ProjectImport#setResolved(Project)} broken.
* @throws ValueDoesNotMatchTypeException Must not occur, otherwise the {@link ValueFactory} or
* {@link net.ssehub.easy.varModel.model.AbstractVariable#setValue(String)} are broken.
* @throws CSTSemanticException Must not occur, otherwise
* {@link Constraint#setConsSyntax(net.ssehub.easy.varModel.cst.ConstraintSyntaxTree)} is broken.
*/
@Test
public void testRemoveLinksToElementsOfRemovedImports() throws ValueDoesNotMatchTypeException, CSTSemanticException,
ModelManagementException {
// Create first imported project with a declaration
Project importedProject = new Project("importedProject");
ProjectImport pImport1 = new ProjectImport(importedProject.getName());
pImport1.setResolved(importedProject);
DecisionVariableDeclaration declImported = new DecisionVariableDeclaration("declImported", IntegerType.TYPE,
importedProject);
importedProject.add(declImported);
// Create main project with the import, a declaration and two constraints (one using to imported element)
Project p = new Project("mainTestProjectResolveImports");
p.addImport(pImport1);
DecisionVariableDeclaration declTop = new DecisionVariableDeclaration("declTop", IntegerType.TYPE, p);
p.add(declTop);
// Constraint using the imported declaration (should be removed together with import)
Constraint constraintToBeRemoved = new Constraint(p);
Variable varTop = new Variable(declTop);
Variable varImported = new Variable(declImported);
OCLFeatureCall comparison1 = new OCLFeatureCall(varTop, OclKeyWords.GREATER, varImported);
constraintToBeRemoved.setConsSyntax(comparison1);
p.add(constraintToBeRemoved);
// Constraint using only declaration of top project (should not be removed)
Constraint constraintToBeKept = new Constraint(p);
OCLFeatureCall comparison2 = new OCLFeatureCall(varTop, OclKeyWords.GREATER,
new ConstantValue(ValueFactory.createValue(declTop.getType(), 42)));
constraintToBeKept.setConsSyntax(comparison2);
p.add(constraintToBeKept);
// Cycling import: Elements of the main project must not be removed
ProjectImport cyclingImport = new ProjectImport(p.getName());
cyclingImport.setResolved(p);
importedProject.addImport(cyclingImport);
// Original project should be valid before using it for testing
ProjectTestUtilities.validateProject(p);
// Create copy
ProjectRewriteVisitor rewriter = new ProjectRewriteVisitor(p, FilterType.ALL);
rewriter.addImportModifier(new ImportRegExNameFilter("^Not a valid name to filter all Imports$", true));
p.accept(rewriter);
ProjectTestUtilities.validateProject(p);
// Test main Project and its import
Assert.assertEquals("Error: Copied project must not contain any imports.", 0, p.getImportsCount());
assertProjectContainment(p, declTop, true, 2);
assertProjectContainment(p, constraintToBeKept, true, 2);
assertProjectContainment(p, constraintToBeRemoved, false, 2);
}
示例15: testProjectModifierByAddingFreezeblock
import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
* Tests one example of a {@link IProjectModifier}, here it tests whether a freeze block may be created in a
* specific project containing elements with a specified rule.
* @throws ModelManagementException If {@link ProjectImport#setResolved(Project)} does not work
*/
@Test
public void testProjectModifierByAddingFreezeblock() throws ModelManagementException {
Project p1 = new Project("orgProject");
DecisionVariableDeclaration decl1 = new DecisionVariableDeclaration("valid_name1", StringType.TYPE, p1);
p1.add(decl1);
DecisionVariableDeclaration decl2 = new DecisionVariableDeclaration("valid_name2", StringType.TYPE, p1);
p1.add(decl2);
DecisionVariableDeclaration decl3 = new DecisionVariableDeclaration("other_name", StringType.TYPE, p1);
p1.add(decl3);
Project p2 = new Project("orgProjectCfg");
ProjectImport pImport = new ProjectImport(p1.getName());
pImport.setResolved(p1);
p2.addImport(pImport);
Assert.assertEquals(0, p2.getElementCount());
ProjectRewriteVisitor rewriter = new ProjectRewriteVisitor(p2, FilterType.ALL);
IProjectModifier modifier = new IProjectModifier() {
@Override
public void modifyProject(Project project, RewriteContext context) {
if (project.getName().endsWith("Cfg")) {
String ns = project.getName().substring(0, project.getName().length() - 3);
DeclarationFinder finder = new DeclarationFinder(project, FilterType.ALL, null);
List<AbstractVariable> foundDecls = finder.getVariableDeclarations(VisibilityType.ALL);
List<IFreezable> toFreeze = new ArrayList<IFreezable>();
for (int i = 0, end = foundDecls.size(); i < end; i++) {
AbstractVariable decl = foundDecls.get(i);
if (decl.getNameSpace().equals(ns) && decl.getName().startsWith("valid_name")
&& decl instanceof IFreezable) {
toFreeze.add((IFreezable) decl);
}
}
IFreezable[] freezes = toFreeze.toArray(new IFreezable[0]);
FreezeBlock block = new FreezeBlock(freezes, null, null, project);
project.add(block);
}
}
};
rewriter.addProjectModifier(modifier);
p2.accept(rewriter);
ProjectTestUtilities.validateProject(p1);
ProjectTestUtilities.validateProject(p2);
Assert.assertEquals(3, p1.getElementCount());
// Test whether the black has been created correctly, dirty: ordering of elements could change
FreezeBlock createdBlock = (FreezeBlock) p2.getElement(0);
Assert.assertNotNull(createdBlock);
Assert.assertEquals(2, createdBlock.getFreezableCount());
Assert.assertSame(decl1, createdBlock.getFreezable(0));
Assert.assertSame(decl2, createdBlock.getFreezable(1));
}