com.evolveum.midpoint.task.api.Task.getExtensionProperty()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中com.evolveum.midpoint.task.api.Task.getExtensionProperty()方法的一些代码示例,展示了Task.getExtensionProperty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.getExtensionProperty()方法的具体详情如下:
包路径:com.evolveum.midpoint.task.api.Task
类名称:Task
方法名:getExtensionProperty

Task.getExtensionProperty介绍

[英]Returns specified property from the extension
[中]从扩展返回指定的属性

代码示例

代码示例来源:origin: Evolveum/midpoint

private <T> T get(Task task, QName propertyName, T defaultValue) {
  PrismProperty<T> property = task.getExtensionProperty(propertyName);
  if (property == null) {
    return defaultValue;
  } else {
    return property.getRealValue();
  }
}

代码示例来源:origin: Evolveum/midpoint

protected Boolean getUseRepositoryDirectlyFromTask(H resultHandler, TaskRunResult runResult,
    Task coordinatorTask, OperationResult opResult) {
  return getRealValue(coordinatorTask.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_USE_REPOSITORY_DIRECTLY));
}

代码示例来源:origin: Evolveum/midpoint

protected QueryType getObjectQueryTypeFromTaskExtension(Task task) {
  return getRealValue(task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY));
}

代码示例来源:origin: Evolveum/midpoint

protected IterationMethodType getIterationMethodFromTask(Task task) {
  return getRealValue(task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_ITERATION_METHOD));
}

代码示例来源:origin: Evolveum/midpoint

protected void assertSyncToken(Task task, Object expectedValue, OperationResult result) throws ObjectNotFoundException, SchemaException {
  PrismProperty<Object> syncTokenProperty = task.getExtensionProperty(SchemaConstants.SYNC_TOKEN);
  if (expectedValue == null && syncTokenProperty == null) {
    return;
  }
  Object syncTokenPropertyValue = syncTokenProperty.getAnyRealValue();
  if (!MiscUtil.equals(expectedValue, syncTokenPropertyValue)) {
    AssertJUnit.fail("Wrong sync token, expected: " + expectedValue + (expectedValue==null?"":(", "+expectedValue.getClass().getName())) +
        ", was: "+ syncTokenPropertyValue + (syncTokenPropertyValue==null?"":(", "+syncTokenPropertyValue.getClass().getName())));
  }
}

代码示例来源:origin: Evolveum/midpoint

private <T> T getTaskPropertyValue(QName propertyName) {
  PrismProperty<T> prop = task.getExtensionProperty(propertyName);
  if (prop == null || prop.isEmpty()) {
    return null;
  }
  
  return prop.getRealValue();
}

代码示例来源:origin: Evolveum/midpoint

protected Integer getWorkerThreadsCount(Task task) {
  PrismProperty<Integer> workerThreadsPrismProperty = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS);
  if (workerThreadsPrismProperty != null && workerThreadsPrismProperty.getRealValue() != null) {
    return workerThreadsPrismProperty.getRealValue();
  } else {
    return null;
  }
}

代码示例来源:origin: Evolveum/midpoint

protected Collection<SelectorOptions<GetOperationOptions>> createSearchOptionsFromTask(H resultHandler, TaskRunResult runResult,
    Task coordinatorTask, OperationResult opResult) {
  SelectorQualifiedGetOptionsType opts = getRealValue(coordinatorTask.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_SEARCH_OPTIONS));
  return MiscSchemaUtil.optionsTypeToOptions(opts, prismContext);
}

代码示例来源:origin: Evolveum/midpoint

protected ModelExecuteOptions getExecuteOptionsFromTask(Task task) {
  PrismProperty<ModelExecuteOptionsType> property = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_EXECUTE_OPTIONS);
  return property != null ? ModelExecuteOptions.fromModelExecutionOptionsType(property.getRealValue()) : null;
}

代码示例来源:origin: Evolveum/midpoint

static Boolean findItemValue(Task task, QName path) throws SchemaException{
  Validate.notNull(task, "Task must not be null.");
  if (task.getExtension() == null) {
    return null;
  }
  PrismProperty<Boolean> item = task.getExtensionProperty(path);
  if (item == null || item.isEmpty()) {
    return null;
  }
  if (item.getValues().size() > 1) {
    throw new SchemaException("Unexpected number of values for option 'dry run'.");
  }
  return item.getValues().iterator().next().getValue();
}

代码示例来源:origin: Evolveum/midpoint

public static ObjectClassComplexTypeDefinition determineObjectClass(RefinedResourceSchema refinedSchema, Task task) throws SchemaException {

  QName objectclass = null;
  PrismProperty<QName> objectclassProperty = task.getExtensionProperty(ModelConstants.OBJECTCLASS_PROPERTY_NAME);
  if (objectclassProperty != null) {
    objectclass = objectclassProperty.getValue().getValue();
  }

  ShadowKindType kind = null;
  PrismProperty<ShadowKindType> kindProperty = task.getExtensionProperty(ModelConstants.KIND_PROPERTY_NAME);
  if (kindProperty != null) {
    kind = kindProperty.getValue().getValue();
  }

  String intent = null;
  PrismProperty<String> intentProperty = task.getExtensionProperty(ModelConstants.INTENT_PROPERTY_NAME);
  if (intentProperty != null) {
    intent = intentProperty.getValue().getValue();
  }

  return determineObjectClassInternal(refinedSchema, objectclass, kind, intent, task);
}

代码示例来源:origin: Evolveum/midpoint

private <T extends ObjectType> ObjectDelta<T> createDeltaFromTask(Task task) throws SchemaException {
  PrismProperty<ObjectDeltaType> objectDeltaType = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_OBJECT_DELTA);
  if (objectDeltaType != null && objectDeltaType.getRealValue() != null) {
    return DeltaConvertor.createObjectDelta(objectDeltaType.getRealValue(), prismContext);
  } else {
    return null;
  }
}

代码示例来源:origin: Evolveum/midpoint

protected Class<? extends ObjectType> getTypeFromTask(Task task, Class<? extends ObjectType> defaultType) {
  Class<? extends ObjectType> objectClass;
  PrismProperty<QName> objectTypePrismProperty = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE);
  if (objectTypePrismProperty != null && objectTypePrismProperty.getRealValue() != null) {
    objectClass = ObjectTypes.getObjectTypeFromTypeQName(objectTypePrismProperty.getRealValue()).getClassDefinition();
  } else {
    objectClass = defaultType;
  }
  return objectClass;
}

代码示例来源:origin: Evolveum/midpoint

public static ModelExecuteOptions getModelExecuteOptions(Task task) throws SchemaException {
  Validate.notNull(task, "Task must not be null.");
  if (task.getExtension() == null) {
    return null;
  }
  //LOGGER.info("Task:\n{}",task.debugDump(1));
  PrismProperty<ModelExecuteOptionsType> item = task.getExtensionProperty(SchemaConstants.C_MODEL_EXECUTE_OPTIONS);
  if (item == null || item.isEmpty()) {
    return null;
  }
  //LOGGER.info("Item:\n{}",item.debugDump(1));
  if (item.getValues().size() > 1) {
    throw new SchemaException("Unexpected number of values for option 'modelExecuteOptions'.");
  }
  ModelExecuteOptionsType modelExecuteOptionsType = item.getValues().iterator().next().getValue();
  if (modelExecuteOptionsType == null) {
    return null;
  }
  //LOGGER.info("modelExecuteOptionsType: {}",modelExecuteOptionsType);
  ModelExecuteOptions modelExecuteOptions = ModelExecuteOptions.fromModelExecutionOptionsType(modelExecuteOptionsType);
  //LOGGER.info("modelExecuteOptions: {}",modelExecuteOptions);
  return modelExecuteOptions;
}

代码示例来源:origin: Evolveum/midpoint

private static boolean isDryRun(Task task){
      
      Validate.notNull(task, "Task must not be null.");
      
      if (task.getExtension() == null){
        return false;
      }
      
      PrismProperty<Boolean> item = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_DRY_RUN);
      if (item == null || item.isEmpty()){
        return false;
      }
      
      if (item.getValues().size() > 1){
        return false;
//                throw new SchemaException("Unexpected number of values for option 'dry run'.");
      }
          
      Boolean dryRun = item.getValues().iterator().next().getValue();
      
      if (dryRun == null){
        return false;
      }
      
      return dryRun.booleanValue(); 
    }

代码示例来源:origin: Evolveum/midpoint

@Override
protected boolean initializeRun(H handler, TaskRunResult runResult,
    Task task, OperationResult opResult) {
  boolean cont = super.initializeRun(handler, runResult, task, opResult);
  if (!cont) {
    return false;
  }
  XMLGregorianCalendar lastScanTimestamp = null;
  PrismProperty<XMLGregorianCalendar> lastScanTimestampProperty = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_LAST_SCAN_TIMESTAMP_PROPERTY_NAME);
  if (lastScanTimestampProperty != null) {
    lastScanTimestamp = lastScanTimestampProperty.getValue().getValue();
  }
  handler.setLastScanTimestamp(lastScanTimestamp);
  handler.setThisScanTimestamp(clock.currentTimeXMLGregorianCalendar());
  return true;
}

代码示例来源:origin: Evolveum/midpoint

@Override
public TaskRunResult run(Task task) {
  OperationResult result = task.getResult().createSubresult(DOT_CLASS + "run");
  TaskRunResult runResult = new TaskRunResult();
  PrismProperty<ExecuteScriptType> executeScriptProperty = task.getExtensionProperty(SchemaConstants.SE_EXECUTE_SCRIPT);
  if (executeScriptProperty == null || executeScriptProperty.getValue().getValue() == null ||
      executeScriptProperty.getValue().getValue().getScriptingExpression() == null) {
    throw new IllegalStateException("There's no script to be run in task " + task + " (property " + SchemaConstants.SE_EXECUTE_SCRIPT + ")");
  }
  try {
    ScriptExecutionResult executionResult = scriptingService.evaluateExpression(executeScriptProperty.getRealValue(), emptyMap(),
        true, task, result);
    LOGGER.debug("Execution output: {} item(s)", executionResult.getDataOutput().size());
    LOGGER.debug("Execution result:\n{}", executionResult.getConsoleOutput());
    result.computeStatus();
    runResult.setRunResultStatus(TaskRunResult.TaskRunResultStatus.FINISHED);
  } catch (ScriptExecutionException | SecurityViolationException | SchemaException | ObjectNotFoundException | ExpressionEvaluationException | CommunicationException | ConfigurationException e) {
    result.recordFatalError("Couldn't execute script: " + e.getMessage(), e);
    LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute script", e);
    runResult.setRunResultStatus(TaskRunResult.TaskRunResultStatus.PERMANENT_ERROR);
  }
  task.getResult().computeStatus();
  runResult.setOperationResult(task.getResult());
  return runResult;
}

代码示例来源:origin: Evolveum/midpoint

@SuppressWarnings("rawtypes")
private PrismProperty getTokenProperty(ResourceShadowDiscriminator shadowCoordinates, Task task, OperationResult result)
    throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, ExpressionEvaluationException {
  PrismProperty tokenProperty = null;
  if (task.getExtension() != null) {
    tokenProperty = task.getExtensionProperty(SchemaConstants.SYNC_TOKEN);
  }
  if (tokenProperty != null && (tokenProperty.getAnyRealValue() == null)) {
    LOGGER.warn("Sync token exists, but it is empty (null value). Ignoring it.");
    if (LOGGER.isTraceEnabled()) {
      LOGGER.trace("Empty sync token property:\n{}", tokenProperty.debugDump());
    }
    tokenProperty = null;
  }
  // if the token is not specified in the task, get the latest token
  if (tokenProperty == null) {
    tokenProperty = shadowCache.fetchCurrentToken(shadowCoordinates, result);
    if (tokenProperty == null || tokenProperty.getValue() == null
        || tokenProperty.getValue().getValue() == null) {
      LOGGER.warn("Empty current sync token provided by {}", shadowCoordinates);
      if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("Empty current sync token property.");
      }
      return null;
    }
  }
  return tokenProperty;
}

代码示例来源:origin: Evolveum/midpoint

PrismProperty delay = taskTemp.getExtensionProperty(SchemaConstants.NOOP_DELAY_QNAME);
AssertJUnit.assertEquals("Delay was not read correctly", 2000, delay.getRealValue());

代码示例来源:origin: Evolveum/midpoint

TaskRunResult runResult = new TaskRunResult();
PrismProperty<Integer> duration = task.getExtensionProperty(DURATION_QNAME);
Integer durationValue = null;
if (duration != null) {

相关文章

微信公众号

最新文章

更多