Search in sources :

Example 26 with Operation

use of org.osate.aadl2.Operation in project oracle-db-examples by oracle.

the class MultiOperation method processChildRowOperation.

/**
 * Process next resultset. Get the child operation from the queue (if any submitted) and pass
 * the resultset to it for the processing. If no child operation in the queue then process resultset
 * with the help of user supplied row handler or the default one. Wait for the child operation or
 * the handler to process all rows of a resultset.
 *
 * @return the completion stage of the child operation.
 * @throws SQLException
 */
private CompletionStage<T> processChildRowOperation() throws SQLException {
    // Get the result set
    ResultSet resultSet = jdbcStatement.getResultSet();
    // Remove child operation, if any exist
    Operation operationFromQueue = resultOperations.poll();
    // Keep as effective final, because it uses in lambda expression
    Operation operation;
    boolean onRowsHandler = (operationFromQueue == null);
    if (onRowsHandler) {
        // Handle using onRows handler.
        operation = new MultiRowOperation<T>(session, group, true);
    } else
        operation = operationFromQueue;
    if (!(operation instanceof ChildRowOperation)) {
        // Throw invalid state
        throw new IllegalStateException("TODO");
    }
    // Trigger child operation to process the resultset
    resultStage = ((ChildRowOperation) operation).setResultSet(resultSet, resultStage);
    if (onRowsHandler)
        resultStage = resultStage.thenRun(() -> rowsHandler.accept(resultNum, (RowOperation<T>) operation));
    // Then again move to moreResult stage to process next resultset.
    return resultStage.thenComposeAsync(((ChildRowOperation) operation)::resultProcessed, getExecutor()).thenComposeAsync(this::checkForMoreResults, getExecutor());
}
Also used : ResultSet(java.sql.ResultSet) RowOperation(jdk.incubator.sql2.RowOperation) RowPublisherOperation(jdk.incubator.sql2.RowPublisherOperation) Operation(jdk.incubator.sql2.Operation) RowCountOperation(jdk.incubator.sql2.RowCountOperation) RowOperation(jdk.incubator.sql2.RowOperation)

Example 27 with Operation

use of org.osate.aadl2.Operation in project osate2 by osate.

the class CreatePropagatonPathPaletteCommand method getOperation.

@Override
public Optional<Operation> getOperation(final GetCreateConnectionOperationContext ctx) {
    // Check the type of the destination business object
    if (!isValidEndpoint(ctx.getDestination())) {
        return Optional.empty();
    }
    // Find the common ancestor which is a source for the classifier to update
    final BusinessObjectContext classifierSourceBoc = BusinessObjectContext.getFirstCommonAncestor(ctx.getSource().getParent(), ctx.getDestination().getParent()).flatMap(ancestor -> ErrorModelGeUtil.getClassifierSourceBoc(ancestor)).orElse(null);
    if (classifierSourceBoc == null) {
        return Optional.empty();
    }
    return ErrorModelGeUtil.createErrorModelSubclauseModifyOperation(classifierSourceBoc, subclause -> {
        final PropagationPath newPath = ErrorModelFactory.eINSTANCE.createPropagationPath();
        final String newName = ErrorModelNamingUtil.buildUniqueIdentifier(subclause.getContainingClassifier(), "new_propagation_path");
        newPath.setName(newName);
        newPath.setSource(createQualifiedPropagationPoint(subclause, ctx.getSource(), classifierSourceBoc));
        newPath.setTarget(createQualifiedPropagationPoint(subclause, ctx.getDestination(), classifierSourceBoc));
        subclause.getPaths().add(newPath);
        return StepResultBuilder.create().showNewBusinessObject(classifierSourceBoc, newPath).build();
    });
}
Also used : URI(org.eclipse.emf.common.util.URI) Feature(org.osate.aadl2.Feature) PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint) GetCreateConnectionOperationContext(org.osate.ge.palette.GetCreateConnectionOperationContext) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) BusinessObjectContext(org.osate.ge.BusinessObjectContext) BasePaletteCommand(org.osate.ge.palette.BasePaletteCommand) CanStartConnectionContext(org.osate.ge.palette.CanStartConnectionContext) CreateConnectionPaletteCommand(org.osate.ge.palette.CreateConnectionPaletteCommand) Subcomponent(org.osate.aadl2.Subcomponent) FeatureGroup(org.osate.aadl2.FeatureGroup) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) SubcomponentElement(org.osate.xtext.aadl2.errormodel.errorModel.SubcomponentElement) QualifiedPropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.QualifiedPropagationPoint) Operation(org.osate.ge.operations.Operation) EObject(org.eclipse.emf.ecore.EObject) PropagationPath(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPath) ErrorModelNamingUtil(org.osate.ge.errormodel.util.ErrorModelNamingUtil) ErrorModelFactory(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelFactory) List(java.util.List) StepResultBuilder(org.osate.ge.operations.StepResultBuilder) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorModelGeUtil(org.osate.ge.errormodel.util.ErrorModelGeUtil) Optional(java.util.Optional) NamedElement(org.osate.aadl2.NamedElement) PropagationPath(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPath) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 28 with Operation

use of org.osate.aadl2.Operation in project osate2 by osate.

the class CreateErrorPathPaletteCommand method getOperation.

@Override
public Optional<Operation> getOperation(final GetCreateConnectionOperationContext ctx) {
    // Check if the destination is a potential end
    if (!ErrorFlowPaletteCommandUtil.isPotentialEnd(ctx.getDestination())) {
        return Optional.empty();
    }
    // Find the common ancestor which is a source for the classifier to update
    final BusinessObjectContext classifierSourceBoc = BusinessObjectContext.getFirstCommonAncestor(ctx.getSource().getParent(), ctx.getDestination().getParent()).flatMap(ancestor -> ErrorModelGeUtil.getClassifierSourceBoc(ancestor)).orElse(null);
    if (classifierSourceBoc == null) {
        return Optional.empty();
    }
    return ErrorModelGeUtil.createErrorModelSubclausePromptAndModifyOperation(classifierSourceBoc, () -> {
        final CombinedErrorModelSubclause combined = CombinedErrorModelSubclause.create(ErrorModelGeUtil.getClassifier(classifierSourceBoc).get());
        // Validate both the source and the destination
        return (ErrorFlowPaletteCommandUtil.validateAndShowError(combined, ctx.getSource(), DirectionType.IN) && ErrorFlowPaletteCommandUtil.validateAndShowError(combined, ctx.getDestination(), DirectionType.OUT)) ? Optional.of(true) : Optional.empty();
    }, (subclause, unused) -> {
        final ErrorPath newFlow = ErrorModelFactory.eINSTANCE.createErrorPath();
        // Set name
        final String newName = ErrorModelNamingUtil.buildUniqueIdentifier(subclause.getContainingClassifier(), "new_error_flow");
        newFlow.setName(newName);
        // Set the incoming and outgoing fields of the flow
        final CombinedErrorModelSubclause combined = CombinedErrorModelSubclause.create(subclause.getContainingClassifier());
        final boolean allSrc = ErrorFlowPaletteCommandUtil.isAll(ctx.getSource());
        if (allSrc) {
            newFlow.setAllIncoming(allSrc);
        } else {
            newFlow.setIncoming(ErrorFlowPaletteCommandUtil.findErrorPropagationOrThrow(combined, ctx.getSource(), DirectionType.IN));
        }
        final boolean allDst = ErrorFlowPaletteCommandUtil.isAll(ctx.getDestination());
        if (allDst) {
            newFlow.setAllOutgoing(allDst);
        } else {
            newFlow.setOutgoing(ErrorFlowPaletteCommandUtil.findErrorPropagationOrThrow(combined, ctx.getDestination(), DirectionType.OUT));
        }
        // Add the flow to the subclause
        subclause.getFlows().add(newFlow);
        return StepResultBuilder.create().showNewBusinessObject(classifierSourceBoc, newFlow).build();
    });
}
Also used : Operation(org.osate.ge.operations.Operation) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) GetCreateConnectionOperationContext(org.osate.ge.palette.GetCreateConnectionOperationContext) ErrorModelNamingUtil(org.osate.ge.errormodel.util.ErrorModelNamingUtil) ErrorModelFactory(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelFactory) StepResultBuilder(org.osate.ge.operations.StepResultBuilder) BusinessObjectContext(org.osate.ge.BusinessObjectContext) BasePaletteCommand(org.osate.ge.palette.BasePaletteCommand) CanStartConnectionContext(org.osate.ge.palette.CanStartConnectionContext) CreateConnectionPaletteCommand(org.osate.ge.palette.CreateConnectionPaletteCommand) ErrorModelGeUtil(org.osate.ge.errormodel.util.ErrorModelGeUtil) Optional(java.util.Optional) DirectionType(org.osate.aadl2.DirectionType) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 29 with Operation

use of org.osate.aadl2.Operation in project osate2 by osate.

the class CreateErrorPropagationPaletteCommand method getOperation.

@Override
public Optional<Operation> getOperation(final GetTargetedOperationContext ctx) {
    final Object bo = ctx.getTarget().getBusinessObject();
    if (bo instanceof Feature) {
        return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> {
            // Find the feature in the context of the EMV subclause. This is needed for reliable serialization.
            final List<URI> path = ErrorModelGeUtil.createQualifiedPropagationPointPath(ctx.getTarget(), ErrorModelGeUtil.getClassifierSourceBoc(ctx.getTarget()).get(), new ArrayList<>());
            newPropagation.setFeatureorPPRef(buildFeatureReference(subclause.eResource().getResourceSet(), path));
        });
    } else if (bo instanceof KeywordPropagationPoint) {
        final KeywordPropagationPoint kw = (KeywordPropagationPoint) bo;
        if (kw.getType() != KeywordPropagationPointType.ALL) {
            return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> newPropagation.setKind(kw.getType().getKind()));
        }
    } else if (bo instanceof PropagationPoint) {
        return createPropgationCreationOperation(ctx.getTarget(), (newPropagation, subclause) -> {
            // Find the propagation in the context of the EMV subclause.
            // Check inherited subclauses as well. This is needed for reliable serialization.
            final CombinedErrorModelSubclause combined = CombinedErrorModelSubclause.create(subclause.getContainingClassifier());
            final String boName = ((PropagationPoint) bo).getName();
            final PropagationPoint pp = combined.getPoints().filter(p -> Objects.equal(p.getName(), boName)).findAny().orElseThrow(() -> new AadlGraphicalEditorException("Unable to find propagation point"));
            final FeatureorPPReference ppRef = ErrorModelFactory.eINSTANCE.createFeatureorPPReference();
            ppRef.setFeatureorPP(pp);
            newPropagation.setFeatureorPPRef(ppRef);
        });
    }
    return Optional.empty();
}
Also used : URI(org.eclipse.emf.common.util.URI) Feature(org.osate.aadl2.Feature) PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint) KeywordPropagationPointType(org.osate.ge.errormodel.model.KeywordPropagationPointType) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) PropagationTreeUtil(org.osate.ge.errormodel.combined.PropagationTreeUtil) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) BusinessObjectContext(org.osate.ge.BusinessObjectContext) BasePaletteCommand(org.osate.ge.palette.BasePaletteCommand) ErrorModelUiUtil(org.osate.ge.errormodel.ui.ErrorModelUiUtil) BiConsumer(java.util.function.BiConsumer) DirectionType(org.osate.aadl2.DirectionType) Objects(com.google.common.base.Objects) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) GetTargetedOperationContext(org.osate.ge.palette.GetTargetedOperationContext) Operation(org.osate.ge.operations.Operation) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) Display(org.eclipse.swt.widgets.Display) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference) ErrorModelFactory(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelFactory) List(java.util.List) StepResultBuilder(org.osate.ge.operations.StepResultBuilder) PropagationNode(org.osate.ge.errormodel.combined.PropagationNode) StringUtil(org.osate.ge.StringUtil) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorModelGeUtil(org.osate.ge.errormodel.util.ErrorModelGeUtil) Optional(java.util.Optional) NamedElement(org.osate.aadl2.NamedElement) TargetedPaletteCommand(org.osate.ge.palette.TargetedPaletteCommand) PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint) KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) EObject(org.eclipse.emf.ecore.EObject) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) Feature(org.osate.aadl2.Feature) URI(org.eclipse.emf.common.util.URI) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference)

Example 30 with Operation

use of org.osate.aadl2.Operation in project osate2 by osate.

the class CreateErrorPropagationPaletteCommand method createPropgationCreationOperation.

/**
 * Creates an operation for creating a propagation for the target.
 * @param target is the target of the propagation. It should be the context which will be the parent of the propagation
 * @param init function called to finish initializing the propagation. It must set the kind or the feature or PP reference.
 * @return the operation or an empty optional if a classifier could not be determined.
 */
private Optional<Operation> createPropgationCreationOperation(final BusinessObjectContext target, final BiConsumer<ErrorPropagation, ErrorModelSubclause> init) {
    return ErrorModelGeUtil.getClassifierSourceBoc(target).flatMap(container -> {
        final AadlPackage pkg = container.getBusinessObject(NamedElement.class).map(ne -> ne.getElementRoot()).map(root -> root instanceof AadlPackage ? ((AadlPackage) root) : null).orElseThrow(() -> new AadlGraphicalEditorException("Unable to find model"));
        return ErrorModelGeUtil.createErrorModelSubclausePromptAndModifyOperation(container, () -> {
            if (propagationAlreadyExists(target)) {
                final String propagationOrContainmentLabel = (containment ? "containment" : "propagation");
                final String inputOrOutputLabel = direction == DirectionType.IN ? "intput" : "output";
                MessageDialog.openError(Display.getDefault().getActiveShell(), "Unable to create " + propagationOrContainmentLabel, "Propagation already exists. A propagation point may only have one " + inputOrOutputLabel + " error " + propagationOrContainmentLabel + " defined.");
                return Optional.empty();
            }
            return ErrorModelUiUtil.promptForTypeSet(pkg);
        }, (subclause, typeSet) -> {
            final ErrorPropagation newPropagation = ErrorModelFactory.eINSTANCE.createErrorPropagation();
            newPropagation.setTypeSet(typeSet);
            newPropagation.setNot(containment);
            newPropagation.setDirection(direction);
            init.accept(newPropagation, subclause);
            subclause.getPropagations().add(newPropagation);
            return StepResultBuilder.create().showNewBusinessObject(target, newPropagation).build();
        });
    });
}
Also used : URI(org.eclipse.emf.common.util.URI) Feature(org.osate.aadl2.Feature) PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint) KeywordPropagationPointType(org.osate.ge.errormodel.model.KeywordPropagationPointType) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ArrayList(java.util.ArrayList) PropagationTreeUtil(org.osate.ge.errormodel.combined.PropagationTreeUtil) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) BusinessObjectContext(org.osate.ge.BusinessObjectContext) BasePaletteCommand(org.osate.ge.palette.BasePaletteCommand) ErrorModelUiUtil(org.osate.ge.errormodel.ui.ErrorModelUiUtil) BiConsumer(java.util.function.BiConsumer) DirectionType(org.osate.aadl2.DirectionType) Objects(com.google.common.base.Objects) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) GetTargetedOperationContext(org.osate.ge.palette.GetTargetedOperationContext) Operation(org.osate.ge.operations.Operation) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) EObject(org.eclipse.emf.ecore.EObject) AadlPackage(org.osate.aadl2.AadlPackage) KeywordPropagationPoint(org.osate.ge.errormodel.model.KeywordPropagationPoint) Display(org.eclipse.swt.widgets.Display) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference) ErrorModelFactory(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelFactory) List(java.util.List) StepResultBuilder(org.osate.ge.operations.StepResultBuilder) PropagationNode(org.osate.ge.errormodel.combined.PropagationNode) StringUtil(org.osate.ge.StringUtil) ErrorModelSubclause(org.osate.xtext.aadl2.errormodel.errorModel.ErrorModelSubclause) ErrorModelGeUtil(org.osate.ge.errormodel.util.ErrorModelGeUtil) Optional(java.util.Optional) NamedElement(org.osate.aadl2.NamedElement) TargetedPaletteCommand(org.osate.ge.palette.TargetedPaletteCommand) AadlPackage(org.osate.aadl2.AadlPackage) AadlGraphicalEditorException(org.osate.ge.aadl2.AadlGraphicalEditorException) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) NamedElement(org.osate.aadl2.NamedElement)

Aggregations

ArrayList (java.util.ArrayList)86 Test (org.junit.Test)75 AbstractMessage (com.google.protobuf.AbstractMessage)65 Operation (com.google.cloud.compute.v1.Operation)49 Operation (com.google.container.v1.Operation)43 StatusCondition (com.google.container.v1.StatusCondition)40 Operation (com.google.container.v1beta1.Operation)24 StatusCondition (com.google.container.v1beta1.StatusCondition)23 InstancesClient (com.google.cloud.compute.v1.InstancesClient)20 Operation (com.reprezen.kaizen.oasparser.model3.Operation)16 Path (com.reprezen.kaizen.oasparser.model3.Path)15 Operation (net.opengis.ows.v_1_0_0.Operation)15 Instance (com.google.cloud.compute.v1.Instance)13 Parameter (com.reprezen.kaizen.oasparser.model3.Parameter)13 DomainType (net.opengis.ows.v_1_0_0.DomainType)13 AttachedDisk (com.google.cloud.compute.v1.AttachedDisk)12 AadlPackage (org.osate.aadl2.AadlPackage)12 InsertInstanceRequest (com.google.cloud.compute.v1.InsertInstanceRequest)11 List (java.util.List)9 Optional (java.util.Optional)9