Get UserTask propery in java API

I have this as part of my bpmn:userTask deff:

      <camunda:property name="myProperty" value="0" />

I have an instanceId and a taskId. How, through the java API, do I get the value?

We use something like this:

    String taskId = ...;
    ProcessEngineServices processEngineServices = ...;
    Task task = processEngineServices.getTaskService().createTaskQuery().taskId(taskId).singleResult();
    String taskDefinitionKey = task.getTaskDefinitionKey();
    String processDefinitionId = task.getProcessDefinitionId();
    Optional<String> myPropertyValue = processEngineServices
            .filter(userTask -> userTask.getId().equals(taskDefinitionKey))
            .flatMap(e -> e.getElementsQuery().filterByType(CamundaProperties.class).list().stream())
            .flatMap(e -> e.getCamundaProperties().stream())
            .filter(e -> e.getCamundaName().equals("myProperty"))

Would I have to go through the BpmnModelInstance to get something at the process level as well?

I have this:

  <bpmn:process id="ny_process" name="My Process" isExecutable="true">
    <camunda:property name="someProperty" value="someValue" />

I would like to get the “someProperty” value. How would I do that?

@mmaceachran yes, just .getModelElementsByType(Process.class)

Hello, after starting my process i have a user task i want to get the user task id in order to complete it .i’m codding with java.