Search in sources :

Example 16 with EnvironmentService

use of com.evolveum.midpoint.studio.impl.EnvironmentService 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 17 with EnvironmentService

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

the class DiffRemoteTask method doRun.

@Override
protected void doRun(ProgressIndicator indicator) {
    super.doRun(indicator);
    indicator.setIndeterminate(false);
    EnvironmentService em = EnvironmentService.getInstance(getProject());
    VirtualFile[] selectedFiles = UIUtil.invokeAndWaitIfNeeded(() -> event.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY));
    List<VirtualFile> toProcess = MidPointUtils.filterXmlFiles(selectedFiles);
    if (toProcess.isEmpty()) {
        MidPointUtils.publishNotification(getProject(), NOTIFICATION_KEY, TITLE, "No files matched for " + TITLE + " (xml)", NotificationType.WARNING);
        return;
    }
    processFiles(indicator, toProcess);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService)

Example 18 with EnvironmentService

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

the class SelectEnvironment method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    EnvironmentService manager = EnvironmentService.getInstance(e.getProject());
    manager.select(environment != null ? environment.getId() : null);
}
Also used : EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService)

Example 19 with EnvironmentService

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

the class ExpanderTest method testExpandFile.

private void testExpandFile(String fileExpected, String fileToExpand, String... expandChunkFiles) {
    for (String s : expandChunkFiles) {
        myFixture.configureByFile(s);
    }
    PsiFile file = myFixture.configureByFile(fileToExpand);
    Editor editor = myFixture.getEditor();
    String text = editor.getDocument().getText();
    Project project = getProject();
    Environment environment = new Environment();
    EnvironmentService es = EnvironmentService.getInstance(project);
    es.add(environment);
    EncryptionService cm = project != null ? EncryptionService.getInstance(project) : null;
    Expander expander = new Expander(environment, cm, project);
    String result = expander.expand(text, file.getVirtualFile());
    LOG.info("Expanded result:\n" + result);
    Diff d = DiffBuilder.compare(Input.fromFile(new File(getTestDataPath(), fileExpected))).withTest(Input.fromString(result)).build();
    if (d.hasDifferences()) {
        LOG.error(d.fullDescription());
        fail();
    }
}
Also used : Project(com.intellij.openapi.project.Project) Expander(com.evolveum.midpoint.studio.impl.Expander) Diff(org.xmlunit.diff.Diff) EncryptionService(com.evolveum.midpoint.studio.impl.EncryptionService) Environment(com.evolveum.midpoint.studio.impl.Environment) PsiFile(com.intellij.psi.PsiFile) EnvironmentService(com.evolveum.midpoint.studio.impl.EnvironmentService) Editor(com.intellij.openapi.editor.Editor) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) PsiFile(com.intellij.psi.PsiFile)

Aggregations

EnvironmentService (com.evolveum.midpoint.studio.impl.EnvironmentService)19 Environment (com.evolveum.midpoint.studio.impl.Environment)12 Project (com.intellij.openapi.project.Project)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 MidPointClient (com.evolveum.midpoint.studio.impl.MidPointClient)4 MidPointService (com.evolveum.midpoint.studio.impl.MidPointService)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 File (java.io.File)3 IOException (java.io.IOException)3 PrismContext (com.evolveum.midpoint.prism.PrismContext)2 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)2 ComboObjectTypes (com.evolveum.midpoint.studio.action.browse.ComboObjectTypes)2 Expander (com.evolveum.midpoint.studio.impl.Expander)2 RunnableUtils (com.evolveum.midpoint.studio.util.RunnableUtils)2 PsiFile (com.intellij.psi.PsiFile)2 NotNull (org.jetbrains.annotations.NotNull)2 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)1 SearchResultList (com.evolveum.midpoint.schema.SearchResultList)1 ComboQueryType (com.evolveum.midpoint.studio.action.browse.ComboQueryType)1 EncryptionService (com.evolveum.midpoint.studio.impl.EncryptionService)1