当前位置: 首页>>代码示例>>Java>>正文


Java Project.addImport方法代码示例

本文整理汇总了Java中net.ssehub.easy.varModel.model.Project.addImport方法的典型用法代码示例。如果您正苦于以下问题:Java Project.addImport方法的具体用法?Java Project.addImport怎么用?Java Project.addImport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.ssehub.easy.varModel.model.Project的用法示例。


在下文中一共展示了Project.addImport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: modifyImports

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Modifies the imports in the main pipeline project <code>mainProject</code>.
 * 
 * @param mainProject
 *            the project to be modified
 * @param command
 *            the command how to modify the project, <code>ADD</code> or <code>DEL</code>
 * @param pImport
 *            the import to be added or deleted
 * @return <code>True</code> if modify successfully, <code>false</code> otherwise
 */
public static boolean modifyImports(Project mainProject, String command, ProjectImport pImport) {
    boolean modified = false;
    switch (command) {
    case ADD: {
        modified = mainProject.addImport(pImport); // it will also check if the import existed before add
        break;
    }
    case DEL: {
        modified = mainProject.removeImport(pImport); // it will also check if the import existed before delete
        break;
    }
    default: {
        break;
    }
    }
    return modified;

}
 
开发者ID:QualiMaster,项目名称:QM-EASyProducer,代码行数:30,代码来源:BasicIVMLModelOperations.java

示例2: simpleImport

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/** 
 * Simple Import with no restrictions. 
 */
@Test
public final void simpleImport() {
    final VarModel model = VarModel.INSTANCE;
    String suffix = "_simpleImport";
    
    Project root = new Project("root" + suffix);
    root.setVersion(new Version(1));
    ProjectImport aImport = new ProjectImport("a" + suffix, null);
    root.addImport(aImport);
    model.updateModel(root, createDummyURI(root));

    Project a = new Project("a" + suffix);
    a.setVersion(new Version(1));
    model.updateModel(a, createDummyURI(a));

    List<IMessage> msgList = VarModel.INSTANCE.resolveImports(root, createDummyURI(root), null);
    Assert.assertEquals(0, msgList.size());
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:22,代码来源:ImportValidationTest.java

示例3: createImport

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Creates an import with simple restriction.
 * 
 * @param project the project to add the import to
 * @param importName the import name (may be a qualified name with interface or without)
 * @param isConflict whether it is a conflict
 * @param operator the operator to be used with the version
 * @param version the version number
 * @throws RestrictionEvaluationException shall not occur
 * @throws ValueDoesNotMatchTypeException shall not occur
 * @throws CSTSemanticException shall not occur
 */
public static void createImport(Project project, String importName, boolean isConflict, String operator, 
    Version version) throws RestrictionEvaluationException, ValueDoesNotMatchTypeException, CSTSemanticException {
    String interfaceName = null;
    int pos = importName.indexOf("::");
    if (pos > 0) {
        interfaceName = importName.substring(pos + 2);
        importName = importName.substring(0, pos);
    }
    DecisionVariableDeclaration[] rVars = ExpressionVersionRestriction.createRestrictionVars(importName);

    ConstraintSyntaxTree expr = new OCLFeatureCall(new CompoundAccess(new Variable(rVars[1]), "version"), operator, 
        new ConstantValue(ValueFactory.createValue(VersionType.TYPE, version)));
    expr.inferDatatype();

    project.addImport(new ProjectImport(importName, interfaceName, isConflict, false, 
        new ExpressionVersionRestriction(expr, rVars[0], rVars[1])));
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:30,代码来源:ImportValidationTest.java

示例4: setUp

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Sets up the project before the test runs.
 * @throws VersionFormatException 
 */
@Before
public void setUp() throws VersionFormatException {
    pro1 = new Project("Name1");
    pro2 = new Project("Name2");
    pro3 = new Project("Name1");
    Version version = new Version("1");
    pro1.setVersion(version);
    pro2.setVersion(version);
    pro3.setVersion(version);
    
    vm = VarModel.INSTANCE;
    events = vm.events();
    
    imp = new ProjectImport("Name1", "Interface");
    pro3.addImport(imp);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:21,代码来源:VarModelTest.java

示例5: testPreserveImports

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Tests whether imports will be copied correctly.
 * @throws ModelManagementException Must not occur,
 * otherwise is the {@link ProjectImport#setResolved(Project)} broken.
 */
@Test
public void testPreserveImports() throws ModelManagementException {
    // Create inner imported Project
    Project importedProject2 = new Project("importedProject2");
    ProjectImport pImport2 = new ProjectImport(importedProject2.getName());
    pImport2.setResolved(importedProject2);
    // Create first imported project
    Project importedProject1 = new Project("importedProject1");
    ProjectImport pImport1 = new ProjectImport(importedProject1.getName());
    importedProject1.addImport(pImport2);
    pImport1.setResolved(importedProject1);
    // Create main project with the import
    Project p = new Project("mainTestProject");
    p.addImport(pImport1);
    ProjectTestUtilities.validateProject(p);
    
    // Create copy to allow comparisons between unfiltered and filtered project.
    ProjectCopyVisitor copynator = new ProjectCopyVisitor(p, FilterType.ALL);
    p.accept(copynator);
    Project copy = copynator.getCopiedProject();
    
    ProjectRewriteVisitor rewriter = new ProjectRewriteVisitor(copy, FilterType.ALL);
    copy.accept(rewriter);
    // Test main Project and its import
    Project importedCopy = assertProjectImport(p, copy);
    // Test first import
    assertProjectImport(importedProject1, importedCopy);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:34,代码来源:ProjectRewriteVisitorTest.java

示例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);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:15,代码来源:BooleanProblemTests.java

示例7: testEmptyProjectImport

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * Tests that a {@link ProjectImport} to an empty project can be copied.
 * @throws ModelManagementException If {@link ProjectImport#setResolved(Project)} is not working
 */
@Test
public void testEmptyProjectImport() throws ModelManagementException {
    Project importedProject = new Project("importedProject_of_testEmptyProjectImport");
    Project mainProject = new Project("mainProject_of_testEmptyProjectImport");
    ProjectImport pImport = new ProjectImport(importedProject.getName());
    pImport.setResolved(importedProject);
    mainProject.addImport(pImport);
    
    copyProject(mainProject);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:15,代码来源:ProjectCopyVisitorTest.java

示例8: 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);
    net.ssehub.easy.reasoning.sseReasoner.AllTests.resultHandler(expectedFailedConstraints, projectP1);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:15,代码来源:QMScenarioTests.java

示例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);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:30,代码来源:ProjectInterfaceTest.java

示例10: localImportRestriction

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
 * a imports c1 and b imports c2 -> valid solution, if (local)blackbox-flag is set.
 * 
 * @throws RestrictionEvaluationException shall not occur
 * @throws ValueDoesNotMatchTypeException shall not occur
 * @throws CSTSemanticException shall not occur
 **/
@Test
public final void localImportRestriction() throws RestrictionEvaluationException, ValueDoesNotMatchTypeException, 
    CSTSemanticException {
    final String suffix = "_localImportRestriction";
    final VarModel model = VarModel.INSTANCE;
    
    Project root = new Project("root" + suffix);
    root.setVersion(new Version(1));
    ProjectImport aImport = new ProjectImport("a" + suffix, null);
    root.addImport(aImport);
    ProjectImport bImport = new ProjectImport("b" + suffix, null);
    root.addImport(bImport);
    model.updateModel(root, createDummyURI(root));
    Project a = new Project("a" + suffix); // imports c1
    a.setVersion(new Version(1));
    createImport(a, "c" + suffix, false, OclKeyWords.LESS, new Version(2));
    model.updateModel(a, createDummyURI(a));
    Project b = new Project("b" + suffix); // imports c2
    b.setVersion(new Version(1));
    createImport(b, "c" + suffix, false, OclKeyWords.GREATER_EQUALS, new Version(2));
    model.updateModel(b, createDummyURI(b));
    Project c1 = new Project("c" + suffix);
    c1.setVersion(new Version(1));
    model.updateModel(c1, createDummyURI(c1));
    Project c2 = new Project("c" + suffix);
    c2.setVersion(new Version(2));
    model.updateModel(c2, createDummyURI(c2));
    List<IMessage> msgList = VarModel.INSTANCE.resolveImports(root, createDummyURI(root), null);
    Assert.assertEquals(0, msgList.size());
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:38,代码来源:ImportValidationTest.java

示例11: invalidImport

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/** 
 * projectimport with missing project. 
 */
@Test
public final void invalidImport() {
    final VarModel model = VarModel.INSTANCE;
    final String suffix = "_invalidImport";
    
    Project root = new Project("root" + suffix);
    root.setVersion(new Version(1));
    ProjectImport aImport = new ProjectImport("b" + suffix, null);
    root.addImport(aImport);
    model.updateModel(root, createDummyURI(root));

    List<IMessage> msgList = VarModel.INSTANCE.resolveImports(root, createDummyURI(root), null);
    Assert.assertNotEquals(0, msgList.size());
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:18,代码来源:ImportValidationTest.java

示例12: circularImports

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/** 
 * Circular project imports. 
 */
@Ignore("currently not needed, check is disabled in import resolver as IVML can cope with that")
@Test
public final void circularImports() {
    final VarModel model = VarModel.INSTANCE;
    final String suffix = "_circularImports";
    
    Project root = new Project("root" + suffix);
    root.setVersion(new Version(1));
    ProjectImport aImport = new ProjectImport("a" + suffix, null);
    root.addImport(aImport);
    model.updateModel(root, createDummyURI(root));
    
    Project a = new Project("a" + suffix);
    a.setVersion(new Version(1));
    ProjectImport bImport = new ProjectImport("b" + suffix, null);
    a.addImport(bImport);
    model.updateModel(a, createDummyURI(a));
    
    Project b = new Project("b" + suffix);
    b.setVersion(new Version(1));
    ProjectImport rootImport = new ProjectImport("root" + suffix, null);
    b.addImport(rootImport);
    model.updateModel(b, createDummyURI(b));
    
    List<IMessage> msgList = VarModel.INSTANCE.resolveImports(root, createDummyURI(root), null);
    Assert.assertNotEquals(0, msgList.size());
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:31,代码来源:ImportValidationTest.java

示例13: handleConfigFile

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
     * Copies the IVML model. Configs will be cleaned.
     * @param relativeFileName The path inside {@link #sourceFolder}.
     * @param destFolder The destination folder where to save the copy.
     * @throws ModelManagementException If IVML files could not be parsed
     * @throws IOException If files could not be copied.
     */
    private void handleConfigFile(String relativeFileName, File destFolder) throws ModelManagementException,
        IOException {
        
        if (!relativeFileName.toLowerCase().matches(REMOVEABLE_CONFIG_EXTENSION)) {
            int lastDot = relativeFileName.lastIndexOf('.');
            int lastSeparator = relativeFileName.lastIndexOf('/');
            if (-1 == lastSeparator) {
                lastSeparator = relativeFileName.lastIndexOf('\\');
            }
            
            String projectName = relativeFileName.substring(lastSeparator + 1, lastDot);
            Project p = ProjectUtilities.loadProject(projectName);
            debugMessage("Filter: " + projectName);
            
            if (BASICS_CONFIG.equals(p.getName())) {
                // Clear Basics Config
                clearRewriter(p, FilterType.NO_IMPORTS);
                rewriter.addModelCopyModifier(new DeclarationNameFilter(new String[] {"IntegerType", "LongType",
                    "StringType", "BooleanType", "FloatType", "DoubleType", "RealType", "ObjectType"}));
                p.accept(rewriter);
            } else if (PIPELINES_CONFIG.equals(p.getName())) {
                // Clear Pipelines Config
                clearRewriter(p, FilterType.NO_IMPORTS);
                rewriter.addImportModifier(new ImportNameFilter(new String[] {"Basics", "Pipelines", "FamiliesCfg",
                    "DataManagementCfg"}));
                p.accept(rewriter);
            } else if (ALGORITHMS_CONFIG.equals(p.getName())) {
                p = processDefaultConfig(p);
            } else if (DATAMGT_CONFIG.equals(p.getName())) {
                p = processDefaultConfig(p);
            } else if (FAMILIES_CONFIG.equals(p.getName())) {
                p = processDefaultConfig(p);
            } else if (HARDWARE_CONFIG.equals(p.getName())) {
                p = processDefaultConfig(p);
            } else if (RECONFIGURABLE_HW_CONFIG.equals(p.getName())) {
                p = processDefaultConfig(p);
//            } else if (INFRASTRUCTURE_CONFIG.equals(p.getName())) {
//                p = processDefaultConfig(p);
//                
                // FIXME SE: Do not remove to much inside InfrastructureCfg
            } else {
                // Clear all other configs
                List<ProjectImport> imports = new ArrayList<ProjectImport>();
                for (int i = 0; i < p.getImportsCount(); i++) {
                    ProjectImport projectImport = p.getImport(i);
                    String importName = projectImport.getName().toLowerCase();
                    if (!(importName + ".ivml").matches(REMOVEABLE_CONFIG_EXTENSION)) {
                        imports.add(projectImport);
                    }
                }
                p.clear();
                for (int i = 0; i < imports.size(); i++) {
                    p.addImport(imports.get(i));
                }
            }
            ProjectUtilities.saveProject(destFolder, p);
        } else {
            debugMessage("Ommiting: " + relativeFileName);
        }
    }
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:68,代码来源:ModelCopy.java

示例14: legitImportAndConflict

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/** 
 * a imports c [possible: c1, c2], but b removes c2 => valid solution. 
 * 
 * @throws RestrictionEvaluationException shall not occur
 * @throws ValueDoesNotMatchTypeException shall not occur
 * @throws CSTSemanticException shall not occur
 */
@Test
public final void legitImportAndConflict() throws RestrictionEvaluationException, ValueDoesNotMatchTypeException, 
    CSTSemanticException {
    // root (v1):
    //   import a
    //   import b
    // a (v1):
    //   import c
    // b (v1):
    //   conflict c>=v1
    // c (v1):
    // c (v2):
    final VarModel model = VarModel.INSTANCE;
    final String suffix = "_legitIMportAndConflict";
    
    Project root = new Project("root" + suffix);
    root.setVersion(new Version(1));
    root.addImport(new ProjectImport("a" + suffix, null));
    root.addImport(new ProjectImport("b" + suffix, null));
    model.updateModel(root, createDummyURI(root));

    Project a = new Project("a" + suffix);
    a.setVersion(new Version(1));
    a.addImport(new ProjectImport("c" + suffix, null));
    model.updateModel(a, createDummyURI(a));

    Project b = new Project("b" + suffix);
    b.setVersion(new Version(1));
    createImport(b, "c" + suffix, true, OclKeyWords.GREATER_EQUALS, new Version(1));
    model.updateModel(b, createDummyURI(b));

    Project c1 = new Project("c" + suffix);
    c1.setVersion(new Version(1));
    model.updateModel(c1, createDummyURI(c1));
    Project c2 = new Project("c" + suffix);
    c2.setVersion(new Version(2));
    model.updateModel(c2, createDummyURI(c2));

    List<IMessage> msgList = VarModel.INSTANCE.resolveImports(root, createDummyURI(root), null);
    Assert.assertTrue(msgList.isEmpty());
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:49,代码来源:ImportValidationTest.java

示例15: main

import net.ssehub.easy.varModel.model.Project; //导入方法依赖的package包/类
/**
     * Short demonstration of the import validation.
     * 
     * @param args unused.
     * @throws URISyntaxException shall not occur
     * @throws RestrictionEvaluationException shall not occur
     * @throws ValueDoesNotMatchTypeException shall not occur
     * @throws CSTSemanticException shall not occur
     */
    public static void main(String[] args) throws URISyntaxException, RestrictionEvaluationException, 
        ValueDoesNotMatchTypeException, CSTSemanticException  {
        String tempURIanfang = "bla/"; // testOnly
        VarModel model = VarModel.INSTANCE;

        Project root = new Project("root");
        root.setVersion(new Version(1));
        root.addImport(new ProjectImport("a", null));
        root.addImport(new ProjectImport("b", null));

        Project a = new Project("a");
        a.setVersion(new Version(1));
        ImportValidationTest.createImport(a, "c", false, IvmlKeyWords.GREATER_EQUALS, new Version(3, 1));
        // A importiert c mit version > 1

        Project b = new Project("b");
        b.setVersion(new Version(1));
        ImportValidationTest.createImport(b, "c", true, IvmlKeyWords.LESS_EQUALS, new Version(3, 1));
        ImportValidationTest.createImport(b, "d", false, IvmlKeyWords.GREATER_EQUALS, new Version(3, 1));

        Project projC1 = new Project("c");
        projC1.setVersion(new Version(3));

        Project projC2 = new Project("c");
        projC2.setVersion(new Version(2));

        Project projC3 = new Project("c");
        projC3.setVersion(new Version(3, 1));

        Project projC32 = new Project("c");
        projC32.setVersion(new Version(3, 2));
        projC32.addImport(new ProjectImport("d", null)); // HIER ist der test, ob das flag funzt
        
        Project projd1 = new Project("d");
        projd1.setVersion(new Version(3));
        
        Project projd2 = new Project("d");
        projd2.setVersion(new Version(3, 2));
//        projC32.addImport(new ProjectImport("a", null, true, false, new VersionRestriction("a", Operator.LESS_EQUALS,
//                new Version(3))));

        model.updateModel(root, new URI(tempURIanfang + root.getName()));
        model.updateModel(a, new URI(tempURIanfang + a.getName()));
        model.updateModel(b, new URI(tempURIanfang + b.getName()));
        model.updateModel(projC1, new URI(tempURIanfang + projC1.getName()));
        model.updateModel(projC2, new URI(tempURIanfang + projC2.getName()));
        model.updateModel(projC3, new URI(tempURIanfang + projC3.getName()));
        model.updateModel(projC32, new URI(tempURIanfang + projC3.getName() + ":)"));
        model.updateModel(projd1, new URI(tempURIanfang + projd1));
        model.updateModel(projd2, new URI(tempURIanfang + projd2));

        VarModel.INSTANCE.resolveImports(root, new URI(tempURIanfang + root.getName()), null);
    }
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:63,代码来源:ImportValidationDemo.java


注:本文中的net.ssehub.easy.varModel.model.Project.addImport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。