Search in sources :

Example 6 with MidPointService

use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.

the class OperationResultDialog method saveResult.

private void saveResult(final Project project, ProgressIndicator indicator, final VirtualFileWrapper fileWrapper, OperationResult result) {
    MidPointService mm = MidPointService.getInstance(project);
    EnvironmentService em = EnvironmentService.getInstance(project);
    Environment environment = em.getSelected();
    RunnableUtils.runWriteActionAndWait(() -> {
        File file = fileWrapper.getFile();
        try {
            if (file.exists()) {
                file.delete();
            }
            file.createNewFile();
        } catch (IOException ex) {
            mm.printToConsole(environment, OperationResultDialog.class, "Couldn't create file " + file.getPath() + " for operation result", ex);
        }
        VirtualFile vFile = fileWrapper.getVirtualFile();
        try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(vFile.getOutputStream(this), vFile.getCharset()))) {
            MidPointClient client = new MidPointClient(project, environment);
            PrismContext ctx = client.getPrismContext();
            PrismSerializer<String> serializer = ctx.serializerFor(PrismContext.LANG_XML);
            String xml = serializer.serializeAnyData(result.createOperationResultType(), SchemaConstantsGenerated.C_OPERATION_RESULT);
            IOUtils.write(xml, out);
        } catch (IOException | SchemaException ex) {
            mm.printToConsole(environment, OperationResultDialog.class, "Couldn't create file " + file.getPath() + " for operation result", ex);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContext(com.evolveum.midpoint.prism.PrismContext) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) MidPointService(com.evolveum.midpoint.studio.impl.MidPointService) MidPointClient(com.evolveum.midpoint.studio.impl.MidPointClient) Environment(com.evolveum.midpoint.studio.impl.Environment) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService) OutputStreamWriter(java.io.OutputStreamWriter) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 7 with MidPointService

use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.

the class DocumentationAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent evt) {
    MidPointService mm = MidPointService.getInstance(evt.getProject());
    MidPointSettings settings = mm.getSettings();
    DocGeneratorOptions opts = settings.getDocGeneratorOptions();
    if (opts == null) {
        opts = DocGeneratorOptions.createDefaultOptions(evt.getProject());
    }
    DocumentationDialog dialog = new DocumentationDialog(evt.getProject(), opts);
    if (!dialog.showAndGet()) {
        return;
    }
    opts = dialog.getOptions();
    settings.setDocGeneratorOptions(opts);
    mm.settingsUpdated();
    GenerateOptions options = DocGeneratorOptions.buildGenerateOptions(opts);
    File exportOutput = opts.getExportOutput();
    File adocOutput = new File(exportOutput.getParent(), exportOutput.getName() + ".adoc");
    options.setAdocOutput(adocOutput);
    this.options = options;
    super.actionPerformed(evt);
}
Also used : DocGeneratorOptions(com.evolveum.midpoint.studio.impl.DocGeneratorOptions) MidPointService(com.evolveum.midpoint.studio.impl.MidPointService) DocumentationDialog(com.evolveum.midpoint.studio.ui.DocumentationDialog) GenerateOptions(com.evolveum.midscribe.generator.GenerateOptions) File(java.io.File) MidPointSettings(com.evolveum.midpoint.studio.impl.MidPointSettings)

Example 8 with MidPointService

use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.

the class VerifyAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getProject();
    VirtualFile[] selectedFiles = ApplicationManager.getApplication().runReadAction((Computable<VirtualFile[]>) () -> e.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY));
    if (selectedFiles == null || selectedFiles.length == 0) {
        MidPointUtils.publishNotification(project, NOTIFICATION_KEY, ACTION_NAME, "No files selected for cleanup", NotificationType.WARNING);
        return;
    }
    List<VirtualFile> toProcess = MidPointUtils.filterXmlFiles(selectedFiles);
    if (toProcess.isEmpty()) {
        MidPointUtils.publishNotification(project, NOTIFICATION_KEY, ACTION_NAME, "No files matched for verification (xml)", NotificationType.WARNING);
        return;
    }
    MidPointService mm = MidPointService.getInstance(project);
    EnvironmentService em = EnvironmentService.getInstance(project);
    Environment env = em.getSelected();
    mm.focusConsole();
    mm.printToConsole(env, VerifyAction.class, "Starting verification using midpoint schema bundled in MidPoint Studio.");
    processFiles(e, mm, env, toProcess);
    mm.printToConsole(env, VerifyAction.class, "Verification finished");
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) MidPointService(com.evolveum.midpoint.studio.impl.MidPointService) Environment(com.evolveum.midpoint.studio.impl.Environment) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService)

Example 9 with MidPointService

use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.

the class FileUtils method createScratchFile.

public static VirtualFile createScratchFile(Project project, Environment env, String fileNamePrefix) throws IOException {
    Map<String, String> params = new HashMap<>();
    // environment short name
    params.put("s", env.getShortName());
    // environment name
    params.put("e", env.getName());
    MidPointService mm = MidPointService.getInstance(project);
    MidPointSettings settings = mm.getSettings();
    return createFile(project, params, null, null, null, settings.getGeneratedFilePattern(), fileNamePrefix, false);
}
Also used : MidPointService(com.evolveum.midpoint.studio.impl.MidPointService) HashMap(java.util.HashMap) MidPointSettings(com.evolveum.midpoint.studio.impl.MidPointSettings)

Aggregations

MidPointService (com.evolveum.midpoint.studio.impl.MidPointService)9 Environment (com.evolveum.midpoint.studio.impl.Environment)4 EnvironmentService (com.evolveum.midpoint.studio.impl.EnvironmentService)3 MidPointSettings (com.evolveum.midpoint.studio.impl.MidPointSettings)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 MidPointClient (com.evolveum.midpoint.studio.impl.MidPointClient)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 OpNode (com.evolveum.midpoint.schema.traces.OpNode)1 OpNodeTreeBuilder (com.evolveum.midpoint.schema.traces.OpNodeTreeBuilder)1 TraceParser (com.evolveum.midpoint.schema.traces.TraceParser)1 MidPointObject (com.evolveum.midpoint.studio.client.MidPointObject)1 DocGeneratorOptions (com.evolveum.midpoint.studio.impl.DocGeneratorOptions)1 ShowResultNotificationAction (com.evolveum.midpoint.studio.impl.ShowResultNotificationAction)1 StudioNameResolver (com.evolveum.midpoint.studio.impl.trace.StudioNameResolver)1