Search in sources :

Example 1 with MidPointSettings

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

the class FileUtils method createFile.

public static <O extends ObjectType> VirtualFile createFile(Project project, Environment env, Class<O> objectType, String oid, String objectName, boolean overwrite) 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, objectType, oid, objectName, settings.getDowloadFilePattern(), null, overwrite);
}
Also used : MidPointService(com.evolveum.midpoint.studio.impl.MidPointService) HashMap(java.util.HashMap) MidPointSettings(com.evolveum.midpoint.studio.impl.MidPointSettings)

Example 2 with MidPointSettings

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

the class DownloadSelectedTypesTask method doRun.

@Override
protected void doRun(ProgressIndicator indicator) {
    super.doRun(indicator);
    MidPointSettings settings = midPointService.getSettings();
    if (settings.getTypesToDownloadLimit() == 0 && settings.getDownloadTypesInclude().isEmpty() && settings.getDownloadTypesExclude().isEmpty()) {
        // probably
        MidPointSettings defaults = MidPointSettings.createDefaultSettings();
        settings.setDownloadTypesInclude(defaults.getDownloadTypesInclude());
        settings.setDownloadTypesExclude(defaults.getDownloadTypesExclude());
        settings.setTypesToDownloadLimit(defaults.getTypesToDownloadLimit());
        midPointService.settingsUpdated();
    }
    if (settings.getTypesToDownloadLimit() <= 0) {
        MidPointUtils.publishNotification(getProject(), NOTIFICATION_KEY, "Download Selected Types", "Download limit set to zero. Done.", NotificationType.WARNING);
        return;
    }
    Environment environment = getEnvironment();
    PrismContext ctx = ServiceFactory.DEFAULT_PRISM_CONTEXT;
    QueryFactory qf = ctx.queryFactory();
    ObjectPaging paging = qf.createPaging(0, settings.getTypesToDownloadLimit(), ctx.path(ObjectType.F_NAME), OrderDirection.ASCENDING);
    ObjectQuery query = qf.createQuery(null, paging);
    List<ObjectTypes> typesToDownload = determineTypesToDownload(settings);
    for (ObjectTypes type : typesToDownload) {
        try {
            DownloadTask dt = new DownloadTask(event, null, type, query, false, false, true);
            dt.setEnvironment(environment);
            dt.setOpenAfterDownload(false);
            dt.download(indicator);
        } catch (Exception ex) {
            midPointService.printToConsole(environment, getClass(), "Couldn't download objects of type '" + type.getValue() + "'. Reason: " + ex.getMessage());
        }
    }
}
Also used : QueryFactory(com.evolveum.midpoint.prism.query.QueryFactory) ObjectPaging(com.evolveum.midpoint.prism.query.ObjectPaging) PrismContext(com.evolveum.midpoint.prism.PrismContext) Environment(com.evolveum.midpoint.studio.impl.Environment) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) MidPointSettings(com.evolveum.midpoint.studio.impl.MidPointSettings)

Example 3 with MidPointSettings

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

the class MidPointSettingsPanel method getSettings.

public MidPointSettings getSettings() {
    MidPointSettings settings = MidPointSettings.createDefaultSettings();
    // we don't want to replace projectId with random id
    settings.setProjectId(this.settings.getProjectId());
    settings.setDowloadFilePattern(downloadPattern.getText());
    settings.setGeneratedFilePattern(generatedPattern.getText());
    settings.setPrintRestCommunicationToConsole(logRestCommunication.isSelected());
    if (StringUtils.isNumeric(restClientTimeout.getText())) {
        settings.setRestResponseTimeout(Integer.parseInt(restClientTimeout.getText()));
    }
    ObjectTypesConverter converter = new ObjectTypesConverter();
    settings.setDownloadTypesInclude(converter.fromString(typesIncluded.getText()));
    settings.setDownloadTypesExclude(converter.fromString(typesExcluded.getText()));
    settings.setTypesToDownloadLimit(Integer.parseInt(typesDownloadLimit.getText()));
    return settings;
}
Also used : ObjectTypesConverter(com.evolveum.midpoint.studio.util.ObjectTypesConverter) MidPointSettings(com.evolveum.midpoint.studio.impl.MidPointSettings)

Example 4 with MidPointSettings

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

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

MidPointSettings (com.evolveum.midpoint.studio.impl.MidPointSettings)5 MidPointService (com.evolveum.midpoint.studio.impl.MidPointService)3 HashMap (java.util.HashMap)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)1 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)1 QueryFactory (com.evolveum.midpoint.prism.query.QueryFactory)1 ObjectTypes (com.evolveum.midpoint.schema.constants.ObjectTypes)1 DocGeneratorOptions (com.evolveum.midpoint.studio.impl.DocGeneratorOptions)1 Environment (com.evolveum.midpoint.studio.impl.Environment)1 DocumentationDialog (com.evolveum.midpoint.studio.ui.DocumentationDialog)1 ObjectTypesConverter (com.evolveum.midpoint.studio.util.ObjectTypesConverter)1 GenerateOptions (com.evolveum.midscribe.generator.GenerateOptions)1 File (java.io.File)1