Search in sources :

Example 1 with ResourceVisualizationDto

use of com.evolveum.midpoint.web.page.admin.resources.dto.ResourceVisualizationDto in project midpoint by Evolveum.

the class PageResourceVisualization method loadVisualizationDto.

@NotNull
private ResourceVisualizationDto loadVisualizationDto() {
    Task task = createSimpleTask(OPERATION_EXPORT_DATA_MODEL);
    OperationResult result = task.getResult();
    String dot;
    try {
        resourceObject.revive(getPrismContext());
        dot = getModelDiagnosticService().exportDataModel(resourceObject.asObjectable(), DataModelVisualizer.Target.DOT, task, result);
    } catch (CommonException | RuntimeException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't export the data model for {}", e, ObjectTypeUtil.toShortString(resourceObject));
        showResult(result);
        throw redirectBackViaRestartResponseException();
    }
    String renderer = DEFAULT_RENDERER;
    Configuration dotConfig = getMidpointConfiguration().getConfiguration(MidpointConfiguration.DOT_CONFIGURATION);
    if (dotConfig != null) {
        renderer = dotConfig.getString(RENDERER, renderer);
    }
    renderer += " -Tsvg";
    StringBuilder output = new StringBuilder();
    try {
        SystemUtil.executeCommand(renderer, dot, output, -1);
        return new ResourceVisualizationDto(dot, output.toString(), null);
    } catch (IOException | RuntimeException e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't execute SVG renderer command: {}", e, renderer);
        return new ResourceVisualizationDto(dot, null, e);
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) MidpointConfiguration(com.evolveum.midpoint.common.configuration.api.MidpointConfiguration) Configuration(org.apache.commons.configuration2.Configuration) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CommonException(com.evolveum.midpoint.util.exception.CommonException) IOException(java.io.IOException) ResourceVisualizationDto(com.evolveum.midpoint.web.page.admin.resources.dto.ResourceVisualizationDto) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

MidpointConfiguration (com.evolveum.midpoint.common.configuration.api.MidpointConfiguration)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 CommonException (com.evolveum.midpoint.util.exception.CommonException)1 ResourceVisualizationDto (com.evolveum.midpoint.web.page.admin.resources.dto.ResourceVisualizationDto)1 IOException (java.io.IOException)1 Configuration (org.apache.commons.configuration2.Configuration)1 NotNull (org.jetbrains.annotations.NotNull)1