Search in sources :

Example 16 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class PageAdminResources method deleteSyncTokenPerformed.

protected void deleteSyncTokenPerformed(AjaxRequestTarget target, ResourceType resourceType) {
    //        ResourceDto dto = model.getObject();
    String resourceOid = resourceType.getOid();
    String handlerUri = "http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3";
    ObjectReferenceType resourceRef = new ObjectReferenceType();
    resourceRef.setOid(resourceOid);
    PrismObject<TaskType> oldTask;
    OperationResult result = new OperationResult(OPERATION_DELETE_SYNC_TOKEN);
    ObjectQuery query = QueryBuilder.queryFor(TaskType.class, getPrismContext()).item(TaskType.F_OBJECT_REF).ref(resourceOid).and().item(TaskType.F_HANDLER_URI).eq(handlerUri).build();
    List<PrismObject<TaskType>> taskList = WebModelServiceUtils.searchObjects(TaskType.class, query, result, this);
    if (taskList.size() != 1) {
        error(getString("pageResource.message.invalidTaskSearch"));
    } else {
        oldTask = taskList.get(0);
        saveTask(oldTask, result);
    }
    result.recomputeStatus();
    showResult(result);
    target.add(getFeedbackPanel());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 17 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class ResourceContentPanel method newTaskPerformed.

private void newTaskPerformed(String category, AjaxRequestTarget target) {
    TaskType taskType = new TaskType();
    PrismProperty<ShadowKindType> pKind;
    try {
        pKind = taskType.asPrismObject().findOrCreateProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND));
        pKind.setRealValue(getKind());
    } catch (SchemaException e) {
        getSession().warn("Could not set kind for new task " + e.getMessage());
    }
    PrismProperty<String> pIntent;
    try {
        pIntent = taskType.asPrismObject().findOrCreateProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT));
        pIntent.setRealValue(getIntent());
    } catch (SchemaException e) {
        getSession().warn("Could not set kind for new task " + e.getMessage());
    }
    PrismObject<ResourceType> resource = getResourceModel().getObject();
    taskType.setObjectRef(ObjectTypeUtil.createObjectRef(resource));
    taskType.setCategory(category);
    setResponsePage(new PageTaskAdd(taskType));
    ;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PageTaskAdd(com.evolveum.midpoint.web.page.admin.server.PageTaskAdd)

Example 18 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestParseTaskBulkAction method assertTask.

private void assertTask(PrismObject<TaskType> task) {
    task.checkConsistence();
    assertEquals("Wrong oid", "44444444-4444-4444-4444-000000001111", task.getOid());
    PrismObjectDefinition<TaskType> usedDefinition = task.getDefinition();
    assertNotNull("No task definition", usedDefinition);
    PrismAsserts.assertObjectDefinition(usedDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "task"), TaskType.COMPLEX_TYPE, TaskType.class);
    assertEquals("Wrong class in task", TaskType.class, task.getCompileTimeClass());
    TaskType taskType = task.asObjectable();
    assertNotNull("asObjectable resulted in null", taskType);
    assertPropertyValue(task, "name", PrismTestUtil.createPolyString("Task2"));
    assertPropertyDefinition(task, "name", PolyStringType.COMPLEX_TYPE, 0, 1);
    assertPropertyValue(task, "taskIdentifier", "44444444-4444-4444-4444-000000001111");
    assertPropertyDefinition(task, "taskIdentifier", DOMUtil.XSD_STRING, 0, 1);
    assertPropertyDefinition(task, "executionStatus", JAXBUtil.getTypeQName(TaskExecutionStatusType.class), 1, 1);
    PrismProperty<TaskExecutionStatusType> executionStatusProperty = task.findProperty(TaskType.F_EXECUTION_STATUS);
    PrismPropertyValue<TaskExecutionStatusType> executionStatusValue = executionStatusProperty.getValue();
    TaskExecutionStatusType executionStatus = executionStatusValue.getValue();
    assertEquals("Wrong execution status", TaskExecutionStatusType.RUNNABLE, executionStatus);
    PrismContainer extension = task.getExtension();
    PrismContainerValue extensionValue = extension.getValue();
    assertTrue("Extension parent", extensionValue.getParent() == extension);
    assertNull("Extension ID", extensionValue.getId());
}
Also used : PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) QName(javax.xml.namespace.QName) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) TaskExecutionStatusType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType)

Example 19 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestParseTaskBulkAction method testParseTaskFile.

@Test
public void testParseTaskFile() throws Exception {
    System.out.println("===[ testParseTaskFile ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    PrismObject<TaskType> task = prismContext.parserFor(TASK_FILE).xml().parse();
    // THEN
    System.out.println("Parsed task:");
    System.out.println(task.debugDump());
    assertTask(task);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType) Test(org.testng.annotations.Test)

Example 20 with TaskType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.

the class TestSecurityBasic method addTask.

private void addTask(String oid, String name, String ownerOid, String handlerUri, Task execTask, OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
    PrismObject<TaskType> task = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(TaskType.class).instantiate();
    task.setOid(oid);
    TaskType taskType = task.asObjectable();
    taskType.setName(createPolyStringType(name));
    if (ownerOid != null) {
        ObjectReferenceType ownerRef = new ObjectReferenceType();
        ownerRef.setOid(ownerOid);
        taskType.setOwnerRef(ownerRef);
    }
    taskType.setHandlerUri(handlerUri);
    modelService.executeChanges(MiscSchemaUtil.createCollection(task.createAddDelta()), null, execTask, result);
}
Also used : ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) TaskType(com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)

Aggregations

TaskType (com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType)88 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)63 Test (org.testng.annotations.Test)50 Task (com.evolveum.midpoint.task.api.Task)47 PrismObject (com.evolveum.midpoint.prism.PrismObject)30 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)25 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)23 AbstractModelIntegrationTest (com.evolveum.midpoint.model.test.AbstractModelIntegrationTest)19 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)18 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)17 PrismAsserts.assertEqualsPolyString (com.evolveum.midpoint.prism.util.PrismAsserts.assertEqualsPolyString)16 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)15 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)15 ArrayList (java.util.ArrayList)14 QName (javax.xml.namespace.QName)13 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)11 ObjectDeltaType (com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType)10 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)8 Checker (com.evolveum.midpoint.test.Checker)8 ObjectChecker (com.evolveum.midpoint.test.ObjectChecker)8