Search in sources :

Example 21 with Context

use of com.google.cloud.dialogflow.v2.Context in project kie-wb-common by kiegroup.

the class ContextPropertyConverter method dmnFromWB.

public static org.kie.dmn.model.v1_1.Context dmnFromWB(final Context wb) {
    org.kie.dmn.model.v1_1.Context result = new org.kie.dmn.model.v1_1.Context();
    result.setId(wb.getId().getValue());
    result.setDescription(wb.getDescription().getValue());
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (ContextEntry ce : wb.getContextEntry()) {
        org.kie.dmn.model.v1_1.ContextEntry ceConverted = ContextEntryPropertyConverter.dmnFromWB(ce);
        result.getContextEntry().add(ceConverted);
    }
    return result;
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) ContextEntry(org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)

Example 22 with Context

use of com.google.cloud.dialogflow.v2.Context in project kie-wb-common by kiegroup.

the class PMMLFunctionEditorDefinition method getModelClass.

@Override
public Optional<Context> getModelClass() {
    final Context context = new Context();
    final ContextEntry documentEntry = new ContextEntry();
    final InformationItem documentEntryVariable = new InformationItem();
    documentEntryVariable.setName(new Name(VARIABLE_DOCUMENT));
    documentEntry.setVariable(documentEntryVariable);
    documentEntry.setExpression(new LiteralExpression());
    context.getContextEntry().add(documentEntry);
    final ContextEntry modelEntry = new ContextEntry();
    final InformationItem modelEntryVariable = new InformationItem();
    modelEntryVariable.setName(new Name(VARIABLE_MODEL));
    modelEntry.setVariable(modelEntryVariable);
    modelEntry.setExpression(new LiteralExpression());
    context.getContextEntry().add(modelEntry);
    return Optional.of(context);
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) HasName(org.kie.workbench.common.dmn.api.definition.HasName)

Example 23 with Context

use of com.google.cloud.dialogflow.v2.Context in project kie-wb-common by kiegroup.

the class ContextEditorDefinition method getModelClass.

@Override
public Optional<Context> getModelClass() {
    // Add one ContextEntry for the User to start with
    final Context context = new Context();
    final ContextEntry contextEntry = new ContextEntry();
    contextEntry.setVariable(new InformationItem());
    context.getContextEntry().add(contextEntry);
    // Add (default) "result" entry
    final ContextEntry resultEntry = new ContextEntry();
    resultEntry.setExpression(new LiteralExpression());
    context.getContextEntry().add(resultEntry);
    return Optional.of(context);
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)

Example 24 with Context

use of com.google.cloud.dialogflow.v2.Context in project kie-wb-common by kiegroup.

the class JavaFunctionEditorDefinitionTest method testModelDefinition.

@Test
public void testModelDefinition() {
    final Optional<Context> oModel = definition.getModelClass();
    assertTrue(oModel.isPresent());
    final Context model = oModel.get();
    assertEquals(2, model.getContextEntry().size());
    assertEquals(JavaFunctionEditorDefinition.VARIABLE_CLASS, model.getContextEntry().get(0).getVariable().getName().getValue());
    assertTrue(model.getContextEntry().get(0).getExpression() instanceof LiteralExpression);
    assertEquals(JavaFunctionEditorDefinition.VARIABLE_METHOD_SIGNATURE, model.getContextEntry().get(1).getVariable().getName().getValue());
    assertTrue(model.getContextEntry().get(1).getExpression() instanceof LiteralExpression);
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Test(org.junit.Test)

Example 25 with Context

use of com.google.cloud.dialogflow.v2.Context in project liferay-ide by liferay.

the class LiferayTomcatServerBehavior method moveContextToAutoDeployDir.

public IStatus moveContextToAutoDeployDir(IModule module, IPath deployDir, IPath baseDir, IPath autoDeployDir, boolean noPath, boolean serverStopped) {
    // $NON-NLS-1$
    IPath confDir = baseDir.append("conf");
    // $NON-NLS-1$
    IPath serverXml = confDir.append("server.xml");
    try (InputStream newInputStream = Files.newInputStream(serverXml.toFile().toPath())) {
        Factory factory = new Factory();
        // $NON-NLS-1$
        factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
        Server publishedServer = (Server) factory.loadDocument(newInputStream);
        ServerInstance publishedInstance = new ServerInstance(publishedServer, null, null);
        IPath contextPath = null;
        if (autoDeployDir.isAbsolute()) {
            contextPath = autoDeployDir;
        } else {
            contextPath = baseDir.append(autoDeployDir);
        }
        File contextDir = contextPath.toFile();
        if (!contextDir.exists()) {
            contextDir.mkdirs();
        }
        Context context = publishedInstance.createContext(-1);
        // $NON-NLS-1$
        context.setReloadable("true");
        final String moduleName = module.getName();
        final String requiredSuffix = ProjectUtil.getRequiredSuffix(module.getProject());
        String contextName = moduleName;
        if (!moduleName.endsWith(requiredSuffix)) {
            contextName = moduleName + requiredSuffix;
        }
        // $NON-NLS-1$
        context.setSource("org.eclipse.jst.jee.server:" + contextName);
        if (// $NON-NLS-1$
        Boolean.valueOf(context.getAttributeValue("antiResourceLocking")).booleanValue()) {
            // $NON-NLS-1$ //$NON-NLS-2$
            context.setAttributeValue("antiResourceLocking", "false");
        }
        // $NON-NLS-1$
        File contextFile = new File(contextDir, contextName + ".xml");
        if (!LiferayTomcatUtil.isExtProjectContext(context)) {
            // If requested, remove path attribute
            if (noPath) {
                // $NON-NLS-1$
                context.removeAttribute("path");
            }
            // need to fix the doc base to contain entire path to help autoDeployer for Liferay
            context.setDocBase(deployDir.toOSString());
            // context.setAttributeValue("antiJARLocking", "true");
            // check to see if we need to move from conf folder
            // IPath existingContextPath = confDir.append("Catalina/localhost").append(contextFile.getName());
            // if (existingContextPath.toFile().exists()) {
            // existingContextPath.toFile().delete();
            // }
            DocumentBuilder builder = XMLUtil.getDocumentBuilder();
            Document contextDoc = builder.newDocument();
            contextDoc.appendChild(contextDoc.importNode(context.getElementNode(), true));
            XMLUtil.save(contextFile.getAbsolutePath(), contextDoc);
        }
    } catch (Exception e) {
        // confDir.toOSString() + ": " + e.getMessage());
        return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPublishConfiguration, new String[] { e.getLocalizedMessage() }), e);
    } finally {
    // monitor.done();
    }
    return Status.OK_STATUS;
}
Also used : Context(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context) MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IPath(org.eclipse.core.runtime.IPath) Server(org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server) IServer(org.eclipse.wst.server.core.IServer) DocumentBuilder(javax.xml.parsers.DocumentBuilder) InputStream(java.io.InputStream) Factory(org.eclipse.jst.server.tomcat.core.internal.xml.Factory) ServerInstance(org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance) Document(org.w3c.dom.Document) File(java.io.File) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

Context (org.eclipse.jst.server.tomcat.core.internal.xml.server40.Context)58 Context (com.microsoft.z3.Context)39 CoreException (org.eclipse.core.runtime.CoreException)34 Context (org.osate.aadl2.Context)31 BoolExpr (com.microsoft.z3.BoolExpr)25 ArrayList (java.util.ArrayList)18 HashMap (java.util.HashMap)18 Test (org.junit.Test)18 ServerInstance (org.eclipse.jst.server.tomcat.core.internal.xml.server40.ServerInstance)17 List (java.util.List)16 Map (java.util.Map)15 Solver (com.microsoft.z3.Solver)13 File (java.io.File)13 IOException (java.io.IOException)11 IPath (org.eclipse.core.runtime.IPath)11 IStatus (org.eclipse.core.runtime.IStatus)11 Status (org.eclipse.core.runtime.Status)11 Factory (org.eclipse.jst.server.tomcat.core.internal.xml.Factory)11 Feature (org.osate.aadl2.Feature)11 FileNotFoundException (java.io.FileNotFoundException)10