use of com.evolveum.midpoint.studio.impl.EnvironmentService 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;
}
use of com.evolveum.midpoint.studio.impl.EnvironmentService 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);
}
});
}
use of com.evolveum.midpoint.studio.impl.EnvironmentService in project midpoint-studio by Evolveum.
the class EnvironmentListDialog method doOKAction.
@Override
protected void doOKAction() {
super.doOKAction();
EnvironmentService manager = EnvironmentService.getInstance(project);
manager.setSettings(panel.getFullSettings());
}
use of com.evolveum.midpoint.studio.impl.EnvironmentService in project midpoint-studio by Evolveum.
the class TestAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent evt) {
if (evt.getProject() == null) {
return;
}
// Project project = evt.getProject();
//
// ResourceWizard wizard = ResourceWizard.createWizard(project);
// wizard.showAndGet();
RunnableUtils.executeWithPluginClassloader(() -> {
EnvironmentService es = EnvironmentService.getInstance(evt.getProject());
MidPointClient client = new MidPointClient(evt.getProject(), es.getSelected(), true, true);
Map<SchemaFileType, String> result = client.getExtensionSchemas();
System.out.println(result);
return result;
});
}
use of com.evolveum.midpoint.studio.impl.EnvironmentService in project midpoint-studio by Evolveum.
the class TestConnectionAction method update.
@Override
public void update(@NotNull AnActionEvent e) {
super.update(e);
Project project = e.getProject();
if (project == null) {
e.getPresentation().setEnabled(false);
return;
}
boolean hasFacet = MidPointUtils.hasMidPointFacet(e.getProject());
if (!hasFacet) {
e.getPresentation().setEnabled(false);
return;
}
EnvironmentService em = EnvironmentService.getInstance(project);
Environment selected = em.getSelected();
e.getPresentation().setEnabled(selected != null);
}
Aggregations