private PrismObject<TaskType> getTaskAsObject(String oid, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException, ObjectNotFoundException { ClusterStatusInformation clusterStatusInformation = getClusterStatusInformation(options, TaskType.class, true, result); // returns null if noFetch is set Task task = getTask(oid, options, result); addTransientTaskInformation(task.getTaskPrismObject(), clusterStatusInformation, SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RUN_START_TIMESTAMP, options), SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RETRY_TIMESTAMP, options), SelectorOptions.hasToLoadPath(TaskType.F_NODE_AS_OBSERVED, options), result); if (SelectorOptions.hasToLoadPath(TaskType.F_SUBTASK, options)) { fillInSubtasks(task, clusterStatusInformation, options, result); } fillOperationExecutionState(task); return task.getTaskPrismObject(); }
private ClusterStatusInformation getClusterStatusInformation(Collection<SelectorOptions<GetOperationOptions>> options, Class<? extends ObjectType> objectClass, boolean allowCached, OperationResult result) { boolean noFetch = GetOperationOptions.isNoFetch(SelectorOptions.findRootOptions(options)); boolean retrieveStatus; if (noFetch) { retrieveStatus = false; } else { if (objectClass.equals(TaskType.class)) { retrieveStatus = SelectorOptions.hasToLoadPath(TaskType.F_NODE_AS_OBSERVED, options); } else if (objectClass.equals(NodeType.class)) { retrieveStatus = true; // implement some determination algorithm if needed } else { throw new IllegalArgumentException("object class: " + objectClass); } } if (retrieveStatus) { return executionManager.getClusterStatusInformation(true, allowCached, result); } else { return null; } }
private void fillInSubtasks(TaskType task, ClusterStatusInformation clusterStatusInformation, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException { boolean retrieveNextRunStartTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RUN_START_TIMESTAMP, options); boolean retrieveRetryTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RETRY_TIMESTAMP, options); boolean retrieveNodeAsObserved = SelectorOptions.hasToLoadPath(TaskType.F_NODE_AS_OBSERVED, options); List<PrismObject<TaskType>> subtasks = listPersistentSubtasksForTask(task.getTaskIdentifier(), result); for (PrismObject<TaskType> subtask : subtasks) { if (subtask.getOid() != null) { addTransientTaskInformation(subtask, clusterStatusInformation, retrieveNextRunStartTime, retrieveRetryTime, retrieveNodeAsObserved, result); fillInSubtasks(subtask.asObjectable(), clusterStatusInformation, options, result); } task.getSubtask().add(subtask.asObjectable()); } }
public SearchResultList<PrismObject<TaskType>> searchTasks(ObjectQuery query, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException { ClusterStatusInformation clusterStatusInformation = getClusterStatusInformation(options, TaskType.class, true, result); // returns null if noFetch is set List<PrismObject<TaskType>> tasksInRepository; try { tasksInRepository = repositoryService.searchObjects(TaskType.class, query, options, result); } catch (SchemaException e) { result.recordFatalError("Couldn't get tasks from repository: " + e.getMessage(), e); throw e; } boolean retrieveNextRunStartTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RUN_START_TIMESTAMP, options); boolean retrieveRetryTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RETRY_TIMESTAMP, options); boolean retrieveNodeAsObserved = SelectorOptions.hasToLoadPath(TaskType.F_NODE_AS_OBSERVED, options); List<PrismObject<TaskType>> retval = new ArrayList<>(); for (PrismObject<TaskType> taskInRepository : tasksInRepository) { TaskType taskInResult = addTransientTaskInformation(taskInRepository, clusterStatusInformation, retrieveNextRunStartTime, retrieveRetryTime, retrieveNodeAsObserved, result); retval.add(taskInResult.asPrismObject()); } result.computeStatus(); return new SearchResultList<>(retval); }
public <T extends ObjectType> void updateLoadedCampaign(PrismObject<T> object, Collection<SelectorOptions<GetOperationOptions>> options, Session session) throws SchemaException { if (!SelectorOptions.hasToLoadPath(AccessCertificationCampaignType.F_CASE, options)) { return; } LOGGER.debug("Loading certification campaign cases."); CriteriaBuilder cb = session.getCriteriaBuilder(); CriteriaQuery cq = cb.createQuery(RAccessCertificationCase.class); cq.where(cb.equal(cq.from(RAccessCertificationCase.class).get("ownerOid"), object.getOid())); Query query = session.createQuery(cq); // TODO fetch only XML representation @SuppressWarnings({"raw", "unchecked"}) List<RAccessCertificationCase> cases = query.list(); if (cases == null || cases.isEmpty()) { return; } AccessCertificationCampaignType campaign = (AccessCertificationCampaignType) object.asObjectable(); List<AccessCertificationCaseType> jaxbCases = campaign.getCase(); for (RAccessCertificationCase rCase : cases) { AccessCertificationCaseType jaxbCase = rCase.toJAXB(prismContext); jaxbCases.add(jaxbCase); } }
private void fillInSubtasks(Task task, ClusterStatusInformation clusterStatusInformation, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult result) throws SchemaException { boolean retrieveNextRunStartTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RUN_START_TIMESTAMP, options); boolean retrieveRetryTime = SelectorOptions.hasToLoadPath(TaskType.F_NEXT_RETRY_TIMESTAMP, options); boolean retrieveNodeAsObserved = SelectorOptions.hasToLoadPath(TaskType.F_NODE_AS_OBSERVED, options); List<Task> subtasks = task.listSubtasks(result); for (Task subtask : subtasks) { if (subtask.isPersistent()) { addTransientTaskInformation(subtask.getTaskPrismObject(), clusterStatusInformation, retrieveNextRunStartTime, retrieveRetryTime, retrieveNodeAsObserved, result); fillInSubtasks(subtask, clusterStatusInformation, options, result); } TaskType subTaskType = subtask.getTaskPrismObject().asObjectable(); task.getTaskPrismObject().asObjectable().getSubtask().add(subTaskType); } }
@Deprecated protected static <T extends ObjectType> void copyToJAXB(RObject<T> repo, ObjectType jaxb, PrismContext prismContext, Collection<SelectorOptions<GetOperationOptions>> options) { Validate.notNull(repo, "Repo object must not be null."); Validate.notNull(jaxb, "JAXB object must not be null."); jaxb.setName(RPolyString.copyToJAXB(repo.getName())); jaxb.setOid(repo.getOid()); jaxb.setVersion(Integer.toString(repo.getVersion())); jaxb.setLifecycleState(repo.getLifecycleState()); if (repo.getSubtype() != null) { jaxb.getSubtype().addAll(repo.getSubtype()); } if (SelectorOptions.hasToLoadPath(ObjectType.F_PARENT_ORG_REF, options)) { List orgRefs = RUtil.safeSetReferencesToList(repo.getParentOrgRef(), prismContext); if (!orgRefs.isEmpty()) { jaxb.getParentOrgRef().addAll(orgRefs); } } }
@Override @NotNull public PrismObject<TaskType> getTaskTypeByIdentifier(String identifier, Collection<SelectorOptions<GetOperationOptions>> options, OperationResult parentResult) throws SchemaException, ObjectNotFoundException { OperationResult result = parentResult.createMinorSubresult(DOT_IMPL_CLASS + "getTaskTypeByIdentifier"); result.addParam("identifier", identifier); result.addContext(OperationResult.CONTEXT_IMPLEMENTATION_CLASS, TaskManagerQuartzImpl.class); ObjectQuery query = prismContext.queryFor(TaskType.class) .item(TaskType.F_TASK_IDENTIFIER).eq(identifier) .build(); List<PrismObject<TaskType>> list = repositoryService.searchObjects(TaskType.class, query, options, result); if (list.isEmpty()) { throw new ObjectNotFoundException("Task with identifier " + identifier + " could not be found"); } else if (list.size() > 1) { throw new IllegalStateException("Found more than one task with identifier " + identifier + " (" + list.size() + " of them)"); } PrismObject<TaskType> retval = list.get(0); if (SelectorOptions.hasToLoadPath(TaskType.F_SUBTASK, options)) { ClusterStatusInformation clusterStatusInformation = getClusterStatusInformation(options, TaskType.class, true, result); // returns null if noFetch is set fillInSubtasks(retval.asObjectable(), clusterStatusInformation, options, result); } result.computeStatusIfUnknown(); return retval; }
public <T extends ObjectType> void updateLoadedLookupTable(PrismObject<T> object, Collection<SelectorOptions<GetOperationOptions>> options, Session session) throws SchemaException { if (!SelectorOptions.hasToLoadPath(LookupTableType.F_ROW, options)) { return; } LOGGER.debug("Loading lookup table data."); GetOperationOptions getOption = findLookupTableGetOption(options); RelationalValueSearchQuery queryDef = getOption == null ? null : getOption.getRelationalValueSearchQuery(); Query query = setupLookupTableRowsQuery(session, queryDef, object.getOid()); if (queryDef != null && queryDef.getPaging() != null) { ObjectPaging paging = queryDef.getPaging(); if (paging.getOffset() != null) { query.setFirstResult(paging.getOffset()); } if (paging.getMaxSize() != null) { query.setMaxResults(paging.getMaxSize()); } } List<RLookupTableRow> rows = query.list(); if (rows == null || rows.isEmpty()) { return; } LookupTableType lookup = (LookupTableType) object.asObjectable(); List<LookupTableRowType> jaxbRows = lookup.getRow(); for (RLookupTableRow row : rows) { LookupTableRowType jaxbRow = row.toJAXB(); jaxbRows.add(jaxbRow); } }
resource, CredentialsCapabilityType.class); if (credentialsCapabilityType != null) { if (SelectorOptions.hasToLoadPath(ctx.getPrismContext().toUniformPath(SchemaConstants.PATH_PASSWORD_VALUE), ctx.getGetOperationOptions())) { attributesToReturn.setReturnPasswordExplicit(true); apply = true; if (SelectorOptions.hasToLoadPath(ctx.path(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS), ctx.getGetOperationOptions())) { attributesToReturn.setReturnAdministrativeStatusExplicit(true); apply = true; if (SelectorOptions.hasToLoadPath(ctx.path(SchemaConstants.PATH_ACTIVATION_VALID_FROM), ctx.getGetOperationOptions())) { attributesToReturn.setReturnValidFromExplicit(true); apply = true; if (SelectorOptions.hasToLoadPath(ctx.path(SchemaConstants.PATH_ACTIVATION_VALID_TO), ctx.getGetOperationOptions())) { attributesToReturn.setReturnValidToExplicit(true); apply = true; if (SelectorOptions.hasToLoadPath(ctx.path(SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS), ctx.getGetOperationOptions())) { attributesToReturn.setReturnAdministrativeStatusExplicit(true); apply = true;
if (SelectorOptions.hasToLoadPath(FocusType.F_JPEG_PHOTO, options)) { caseHelper.updateLoadedCampaign(prismObject, options, session); } else if (TaskType.class.equals(prismObject.getCompileTimeClass())) { if (SelectorOptions.hasToLoadPath(TaskType.F_RESULT, options)) { Query query = session.getNamedQuery("get.taskResult"); query.setParameter("oid", prismObject.getOid());
return; final boolean retrieveWorkItems = SelectorOptions.hasToLoadPath(SchemaConstants.PATH_WORKFLOW_CONTEXT_WORK_ITEM, options); if (!retrieveWorkItems) {
}; boolean fetchAssociations = SelectorOptions.hasToLoadPath(ShadowType.F_ASSOCIATION, options);