use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.
the class ExtractLocalizationPropertiesAction method dumpToConsole.
private void dumpToConsole(Project project, Map<String, String> properties, Map<String, String> existing) {
MidPointService ms = MidPointService.getInstance(project);
StringBuilder sb = new StringBuilder();
sb.append("Generated localization:\n");
List<String> keys = new ArrayList<>();
properties.keySet().forEach(k -> {
if (existing != null && !existing.containsKey(k)) {
keys.add(k);
}
});
Collections.sort(keys);
keys.forEach(k -> sb.append(k + "=" + properties.get(k)).append('\n'));
ms.printToConsole(null, TestAction.class, sb.toString());
}
use of com.evolveum.midpoint.studio.impl.MidPointService 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);
}
use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.
the class TraceViewEditor method initialize.
private void initialize() {
OpNode root;
long start = System.currentTimeMillis();
LOG.info("Initializing TraceViewEditor");
try (InputStream is = file.getInputStream()) {
String extension = file.getExtension();
boolean isZip = extension != null && extension.equalsIgnoreCase("zip");
PrismContext prismContext = MidPointUtils.DEFAULT_PRISM_CONTEXT;
TraceParser parser = new TraceParser(prismContext);
TracingOutputType tracingOutput = parser.parse(is, isZip, file.getCanonicalPath());
LOG.info("Initializing TraceViewEditor - parsed tracing output: " + (System.currentTimeMillis() - start) + " ms");
StudioNameResolver nameResolver = new StudioNameResolver(tracingOutput.getDictionary(), file);
List<OpNode> data = new OpNodeTreeBuilder(prismContext).build(tracingOutput, nameResolver);
if (data.size() == 1) {
root = data.get(0);
} else {
throw new IllegalStateException("Unexpected # of OpNode objects: " + data.size());
}
LOG.info("Initializing TraceViewEditor - built op node tree: " + (System.currentTimeMillis() - start) + " ms");
} catch (Exception ex) {
MidPointService mm = MidPointService.getInstance(project);
mm.printToConsole(null, TraceViewEditor.class, "Couldn't load file", ex, ConsoleViewContentType.LOG_ERROR_OUTPUT);
MidPointUtils.publishExceptionNotification(project, null, TraceViewEditor.class, NOTIFICATION_KEY, "Couldn't load file", ex);
ex.printStackTrace();
root = null;
}
if (root != null) {
PresentationInitializer.initialize(root);
}
opTreePanel = new OpTreePanel(project, root);
wrapper.setContent(opTreePanel);
}
use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.
the class GeneratorTask method uploadContent.
private void uploadContent(ProgressIndicator indicator, String content) {
Project project = getProject();
Environment env = getEnvironment();
updateIndicator(indicator, "Content created, uploading to " + env.getName());
MidPointService mm = MidPointService.getInstance(project);
MidPointClient client = new MidPointClient(project, env);
List<MidPointObject> objects = MidPointUtils.parseText(project, content, null, NOTIFICATION_KEY);
int fail = 0;
int success = 0;
for (MidPointObject object : objects) {
try {
OperationResult result = UploadExecuteTask.uploadExecute(client, object);
boolean problem = result != null && !result.isSuccess();
if (problem) {
fail++;
String msg = "Upload status of " + object.getName() + " was " + result.getStatus();
mm.printToConsole(env, getClass(), msg);
MidPointUtils.publishNotification(project, NOTIFICATION_KEY, "Warning", msg, NotificationType.WARNING, new ShowResultNotificationAction(result));
} else {
success++;
mm.printToConsole(env, getClass(), "Content uploaded successfuly");
}
} catch (Exception ex) {
fail++;
mm.printToConsole(env, getClass(), "Couldn't upload generated content. Reason: " + ex.getMessage());
MidPointUtils.publishExceptionNotification(project, env, GeneratorTask.class, NOTIFICATION_KEY, "Couldn't upload generated content", ex);
}
}
showNotificationAfterFinish(project, success, fail);
updateIndicator(indicator, "Content uploaded");
}
use of com.evolveum.midpoint.studio.impl.MidPointService in project midpoint-studio by Evolveum.
the class BrowseToolPanel method createFilter.
private ObjectFilter createFilter(PrismContext ctx, boolean oid, boolean name) {
String text = query.getText();
if (StringUtils.isEmpty(text)) {
return null;
}
List<String> filtered = new ArrayList<>();
String[] items = text.split("\n");
for (String item : items) {
item = item.trim();
if (StringUtils.isEmpty(item)) {
continue;
}
filtered.add(item);
}
if (filtered.isEmpty()) {
return null;
}
QueryFactory qf = ctx.queryFactory();
OrFilter or = qf.createOr();
if (oid) {
List<String> filteredOids = filtered;
if (name) {
// if search by name or oid is used, filter out items that can't be used in oid filter
filteredOids = filteredOids.stream().filter(s -> MidPointUtils.UUID_PATTERN.matcher(s).matches()).collect(Collectors.toList());
if (filteredOids.size() != filtered.size()) {
MidPointService ms = MidPointService.getInstance(project);
EnvironmentService em = EnvironmentService.getInstance(project);
Environment env = em.getSelected();
ms.printToConsole(env, BrowseToolPanel.class, "Items in search filed that are not valid OIDs were filtered out (" + (filtered.size() - filteredOids.size()) + ").");
}
}
if (!filteredOids.isEmpty()) {
InOidFilter inOid = qf.createInOid(filteredOids);
or.addCondition(inOid);
}
}
if (name) {
PrismPropertyDefinition def = ctx.getSchemaRegistry().findPropertyDefinitionByElementName(ObjectType.F_NAME);
QName matchingRule = PrismConstants.POLY_STRING_NORM_MATCHING_RULE_NAME;
List<ObjectFilter> filters = new ArrayList<>();
for (String s : filtered) {
ObjectFilter filter = Objects.equals(nameFilterType, Constants.Q_EQUAL_Q) ? EqualFilterImpl.createEqual(ctx.path(ObjectType.F_NAME), def, matchingRule, ctx, s) : SubstringFilterImpl.createSubstring(ctx.path(ObjectType.F_NAME), def, ctx, matchingRule, s, false, false);
filters.add(filter);
}
OrFilter nameOr = qf.createOr(filters);
or.addCondition(nameOr);
}
return or;
}
Aggregations