Search in sources :

Example 56 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class AuditLogViewerPanel method addOrReplaceTable.

private void addOrReplaceTable(Form mainForm) {
    AuditEventRecordProvider provider = new AuditEventRecordProvider(AuditLogViewerPanel.this) {

        private static final long serialVersionUID = 1L;

        public Map<String, Object> getParameters() {
            Map<String, Object> parameters = new HashMap<String, Object>();
            AuditSearchDto search = auditSearchDto.getObject();
            parameters.put("from", search.getFrom());
            parameters.put("to", search.getTo());
            if (search.getChannel() != null) {
                parameters.put("channel", QNameUtil.qNameToUri(search.getChannel()));
            }
            parameters.put("hostIdentifier", search.getHostIdentifier());
            if (search.getInitiatorName() != null) {
                parameters.put("initiatorName", search.getInitiatorName().getOid());
            }
            if (search.getTargetOwnerName() != null) {
                parameters.put("targetOwnerName", search.getTargetOwnerName().getOid());
            }
            List<String> targetOids = new ArrayList<>();
            if (isNotEmpty(search.getTargetNamesObjects())) {
                targetOids.addAll(search.getTargetNamesObjects().stream().map(ObjectType::getOid).collect(toList()));
            }
            if (isNotEmpty(search.getTargetNames())) {
                targetOids.addAll(search.getTargetNames().stream().map(ObjectReferenceType::getOid).collect(toList()));
            }
            if (!targetOids.isEmpty()) {
                parameters.put("targetNames", targetOids);
            }
            if (search.getChangedItem().toItemPath() != null) {
                ItemPath itemPath = search.getChangedItem().toItemPath();
                parameters.put("changedItem", CanonicalItemPath.create(itemPath).asString());
            }
            parameters.put("eventType", search.getEventType());
            parameters.put("eventStage", search.getEventStage());
            parameters.put("outcome", search.getOutcome());
            if (isNotEmpty(search.getvalueRefTargetNames())) {
                parameters.put(AuditEventRecordProvider.VALUE_REF_TARGET_NAMES_KEY, search.getvalueRefTargetNames().stream().map(ObjectType::getName).map(PolyStringType::getOrig).collect(toList()));
            }
            return parameters;
        }

        @Override
        protected void saveCurrentPage(long from, long count) {
            if (count != 0) {
                auditLogStorage.setPageNumber(from / count);
            }
        }
    };
    UserProfileStorage userProfile = pageBase.getSessionStorage().getUserProfile();
    int pageSize = DEFAULT_PAGE_SIZE;
    if (userProfile.getTables().containsKey(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER)) {
        pageSize = userProfile.getPagingSize(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER);
    }
    List<IColumn<AuditEventRecordType, String>> columns = initColumns();
    BoxedTablePanel<AuditEventRecordType> table = new BoxedTablePanel<AuditEventRecordType>(ID_TABLE, provider, columns, UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER, pageSize) {

        private static final long serialVersionUID = 1L;

        @Override
        protected WebMarkupContainer createButtonToolbar(String id) {
            String fileName = "AuditLogViewer_" + createStringResource("MainObjectListPanel.exportFileName").getString();
            CSVDataExporter csvDataExporter = new CSVDataExporter() {

                @Override
                public <T> void exportData(IDataProvider<T> dataProvider, List<IExportableColumn<T, ?>> columns, OutputStream outputStream) throws IOException {
                    ((AuditEventRecordProvider) dataProvider).setExportSize(true);
                    super.exportData(dataProvider, columns, outputStream);
                    ((AuditEventRecordProvider) dataProvider).setExportSize(false);
                }
            };
            ResourceStreamResource resource = (new ResourceStreamResource() {

                protected IResourceStream getResourceStream() {
                    return new ExportToolbar.DataExportResourceStreamWriter(csvDataExporter, getAuditLogViewerTable().getDataTable());
                }
            }).setFileName(fileName + "." + csvDataExporter.getFileNameExtension());
            AbstractLink exportDataLink = (new ResourceLink(id, resource)).setBody(csvDataExporter.getDataFormatNameModel());
            exportDataLink.add(new AttributeAppender("class", " btn btn-primary btn-sm"));
            return exportDataLink;
        }

        @Override
        public void setShowPaging(boolean show) {
        //we don't need to do anything here
        }
    };
    table.setShowPaging(true);
    table.setCurrentPage(auditLogStorage.getPageNumber());
    table.setOutputMarkupId(true);
    mainForm.addOrReplace(table);
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) CSVDataExporter(org.apache.wicket.extensions.markup.html.repeater.data.table.export.CSVDataExporter) HashMap(java.util.HashMap) AuditSearchDto(com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) IDataProvider(org.apache.wicket.markup.repeater.data.IDataProvider) AuditEventRecordProvider(com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordProvider) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ResourceStreamResource(org.apache.wicket.request.resource.ResourceStreamResource) ResourceLink(org.apache.wicket.markup.html.link.ResourceLink) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) BoxedTablePanel(com.evolveum.midpoint.web.component.data.BoxedTablePanel) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AuditEventRecordType(com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType) AbstractLink(org.apache.wicket.markup.html.link.AbstractLink) CanonicalItemPath(com.evolveum.midpoint.prism.path.CanonicalItemPath) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 57 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class ReportDto method getObject.

public PrismObject<ReportType> getObject() {
    if (reportType == null) {
        reportType = new ReportType();
        //TODO FIXME temporary every new report will be set as parent report
        reportType.setParent(Boolean.TRUE);
    }
    reportType.setName(new PolyStringType(name));
    reportType.setExport(exportType);
    reportType.setTemplate(jasperReportDto.getTemplate());
    reportType.setTemplateStyle(templateStyle);
    reportType.setDescription(description);
    reportType.setVirtualizer(virtualizer);
    reportType.setVirtualizerKickOn(virtualizerKickOn);
    reportType.setMaxPages(maxPages);
    reportType.setTimeout(timeout);
    return reportType.asPrismObject();
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ReportType(com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType)

Example 58 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class ManualConnectorInstance method addCase.

private PrismObject<CaseType> addCase(String description, OperationResult result) throws SchemaException, ObjectAlreadyExistsException {
    PrismObject<CaseType> acase = getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(CaseType.class).instantiate();
    CaseType caseType = acase.asObjectable();
    String caseOid = OidUtil.generateOid();
    caseType.setOid(caseOid);
    // TODO: human-readable case ID
    caseType.setName(new PolyStringType(caseOid));
    caseType.setDescription(description);
    // subtype
    caseType.setState(SchemaConstants.CASE_STATE_OPEN);
    // TODO: case payload
    // TODO: a lot of other things
    // TODO: move to case-manager
    LOGGER.info("CREATING CASE:\n{}", acase.debugDump(1));
    repositoryService.addObject(acase, null, result);
    return acase;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) CaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType)

Example 59 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class AddGetObjectTest method addGetSyncDescription.

@Test
public void addGetSyncDescription() throws Exception {
    PrismObjectDefinition accDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class);
    PrismObject<ShadowType> shadow = accDef.instantiate();
    final Date TIME = new Date();
    ShadowType shadowType = shadow.asObjectable();
    shadowType.setName(new PolyStringType("sync desc test"));
    SynchronizationSituationDescriptionType desc = new SynchronizationSituationDescriptionType();
    desc.setChannel("channel");
    desc.setSituation(SynchronizationSituationType.LINKED);
    desc.setTimestamp(XMLGregorianCalendarType.asXMLGregorianCalendar(TIME));
    shadowType.getSynchronizationSituationDescription().add(desc);
    OperationResult result = new OperationResult("sync desc test");
    String oid = repositoryService.addObject(shadowType.asPrismObject(), null, result);
    shadow = repositoryService.getObject(ShadowType.class, oid, null, result);
    shadowType = shadow.asObjectable();
    desc = shadowType.getSynchronizationSituationDescription().get(0);
    AssertJUnit.assertEquals("Times don't match", TIME, XMLGregorianCalendarType.asDate(desc.getTimestamp()));
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test)

Example 60 with PolyStringType

use of com.evolveum.prism.xml.ns._public.types_3.PolyStringType in project midpoint by Evolveum.

the class ConcurrencyTest method concurrency010_SearchIterative.

@Test(enabled = true)
public void concurrency010_SearchIterative() throws Exception {
    String name = "Test10";
    final String newFullName = "new-full-name";
    final File file = new File("src/test/resources/concurrency/user.xml");
    PrismObject<UserType> user = prismContext.parseObject(file);
    user.asObjectable().setName(new PolyStringType(name));
    final OperationResult result = new OperationResult("Concurrency Test10");
    String oid = repositoryService.addObject(user, null, result);
    repositoryService.searchObjectsIterative(UserType.class, QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_NAME).eqPoly(name).matchingOrig().build(), new ResultHandler<UserType>() {

        @Override
        public boolean handle(PrismObject<UserType> object, OperationResult parentResult) {
            LOGGER.info("Handling " + object + "...");
            ObjectDelta delta = ObjectDelta.createModificationReplaceProperty(UserType.class, object.getOid(), UserType.F_FULL_NAME, prismContext, new PolyString(newFullName));
            try {
                repositoryService.modifyObject(UserType.class, object.getOid(), delta.getModifications(), parentResult);
            } catch (Exception e) {
                throw new RuntimeException("Exception in handle method", e);
            }
            return true;
        }
    }, null, false, result);
    PrismObject<UserType> reloaded = repositoryService.getObject(UserType.class, oid, null, result);
    AssertJUnit.assertEquals("Full name was not changed", newFullName, reloaded.asObjectable().getFullName().getOrig());
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) File(java.io.File) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SQLException(java.sql.SQLException) Test(org.testng.annotations.Test)

Aggregations

PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)94 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)28 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)26 Test (org.testng.annotations.Test)23 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)20 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)14 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)12 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)12 QName (javax.xml.namespace.QName)11 Task (com.evolveum.midpoint.task.api.Task)10 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)10 File (java.io.File)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)9 OrgType (com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType)8 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)7 ArrayList (java.util.ArrayList)7 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)5 AbstractInternalModelIntegrationTest (com.evolveum.midpoint.model.impl.AbstractInternalModelIntegrationTest)4 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4