You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by GitBox <gi...@apache.org> on 2022/09/19 13:45:24 UTC

[GitHub] [brooklyn-server] ahgittin commented on a diff in pull request #1358: Initial workflow implementation

ahgittin commented on code in PR #1358:
URL: https://github.com/apache/brooklyn-server/pull/1358#discussion_r974266182


##########
core/src/main/java/org/apache/brooklyn/core/workflow/steps/SetSensorWorkflowStep.java:
##########
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.core.workflow.steps;
+
+import com.google.common.reflect.TypeToken;
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.api.mgmt.classloading.BrooklynClassLoadingContext;
+import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.core.typereg.RegisteredTypes;
+import org.apache.brooklyn.core.workflow.WorkflowExecutionContext;
+import org.apache.brooklyn.core.workflow.WorkflowStepDefinition;
+import org.apache.brooklyn.util.core.flags.BrooklynTypeNameResolution;
+import org.apache.brooklyn.util.core.task.Tasks;
+import org.apache.brooklyn.util.text.Strings;
+import org.apache.brooklyn.util.time.Duration;
+import org.apache.brooklyn.util.time.Time;
+
+public class SetSensorWorkflowStep extends WorkflowStepDefinition {
+
+    EntityValueToSet sensor;
+    Object value;
+
+    public EntityValueToSet getSensor() {
+        return sensor;
+    }
+
+    public Object getValue() {
+        return value;
+    }
+
+    public void setValue(Object value) {
+        this.value = value;
+    }
+
+    @Override
+    public void setShorthand(String expression) {
+        this.sensor = EntityValueToSet.parseFromShorthand(expression, this::setValue);
+    }
+
+    @Override
+    protected Task<?> newTask(String name, WorkflowExecutionContext workflowExecutionContext) {
+        return Tasks.create(getDefaultTaskName(workflowExecutionContext), () -> {

Review Comment:
   good spot, needs tidying.  the `name` of the current step is now available in the `workflowExecutionContext`, and included in some cases, so i think not needed on this api.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@brooklyn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org