Search in sources :

Example 31 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class TestUtil method currentTime.

public static XMLGregorianCalendar currentTime() {
    // This cannot use XmlTypeConverter as we want to use also in tests that do not depend on prism
    GregorianCalendar gregorianCalendar = new GregorianCalendar();
    gregorianCalendar.setTimeInMillis(System.currentTimeMillis());
    return getDatatypeFactory().newXMLGregorianCalendar(gregorianCalendar);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 32 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class LensUtil method createActivationTimestampDelta.

public static PropertyDelta<XMLGregorianCalendar> createActivationTimestampDelta(ActivationStatusType status, XMLGregorianCalendar now, PrismContainerDefinition<ActivationType> activationDefinition, OriginType origin) {
    QName timestampPropertyName;
    if (status == null || status == ActivationStatusType.ENABLED) {
        timestampPropertyName = ActivationType.F_ENABLE_TIMESTAMP;
    } else if (status == ActivationStatusType.DISABLED) {
        timestampPropertyName = ActivationType.F_DISABLE_TIMESTAMP;
    } else if (status == ActivationStatusType.ARCHIVED) {
        timestampPropertyName = ActivationType.F_ARCHIVE_TIMESTAMP;
    } else {
        throw new IllegalArgumentException("Unknown activation status " + status);
    }
    PrismPropertyDefinition<XMLGregorianCalendar> timestampDef = activationDefinition.findPropertyDefinition(timestampPropertyName);
    PropertyDelta<XMLGregorianCalendar> timestampDelta = timestampDef.createEmptyDelta(new ItemPath(FocusType.F_ACTIVATION, timestampPropertyName));
    timestampDelta.setValueToReplace(new PrismPropertyValue<XMLGregorianCalendar>(now, origin, null));
    return timestampDelta;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) QName(javax.xml.namespace.QName) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 33 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class PageCertDecisions method initColumns.

//	private void addVisibleOnWarningBehavior(Component c) {
//		c.add(new VisibleEnableBehaviour() {
//			@Override
//			public boolean isVisible() {
//				return PageCertDecisions.this.getFeedbackMessages().hasMessage(FeedbackMessage.WARNING);
//			}
//		});
//	}
private List<IColumn<CertWorkItemDto, String>> initColumns() {
    List<IColumn<CertWorkItemDto, String>> columns = new ArrayList<>();
    IColumn<CertWorkItemDto, String> column;
    column = new CheckBoxHeaderColumn<>();
    columns.add(column);
    column = helper.createTypeColumn(OBJECT, this);
    columns.add(column);
    column = helper.createObjectNameColumn(this, "PageCertDecisions.table.objectName");
    columns.add(column);
    column = helper.createTypeColumn(TARGET, this);
    columns.add(column);
    column = helper.createTargetNameColumn(this, "PageCertDecisions.table.targetName");
    columns.add(column);
    column = helper.createDetailedInfoColumn(this);
    columns.add(column);
    column = helper.createConflictingNameColumn(this, "PageCertDecisions.table.conflictingTargetName");
    columns.add(column);
    if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_CERTIFICATION_ALL_URL, AuthorizationConstants.AUTZ_UI_CERTIFICATION_CAMPAIGN_URL)) {
        column = new LinkColumn<CertWorkItemDto>(createStringResource("PageCertDecisions.table.campaignName"), SearchingUtils.CAMPAIGN_NAME, CertWorkItemDto.F_CAMPAIGN_NAME) {

            @Override
            public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, IModel<CertWorkItemDto> rowModel) {
                super.populateItem(item, componentId, rowModel);
                AccessCertificationCampaignType campaign = rowModel.getObject().getCampaign();
                if (campaign != null && campaign.getDescription() != null) {
                    item.add(AttributeModifier.replace("title", campaign.getDescription()));
                    item.add(new TooltipBehavior());
                }
            }

            @Override
            public void onClick(AjaxRequestTarget target, IModel<CertWorkItemDto> rowModel) {
                CertWorkItemDto dto = rowModel.getObject();
                PageParameters parameters = new PageParameters();
                parameters.add(OnePageParameterEncoder.PARAMETER, dto.getCampaignRef().getOid());
                navigateToNext(PageCertCampaign.class, parameters);
            }
        };
    } else {
        column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.campaignName"), SearchingUtils.CAMPAIGN_NAME) {

            @Override
            public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
                item.add(new Label(componentId, new AbstractReadOnlyModel<Object>() {

                    @Override
                    public Object getObject() {
                        return rowModel.getObject().getCampaignName();
                    }
                }));
            }
        };
    }
    columns.add(column);
    column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.campaignStage")) {

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
            item.add(new Label(componentId, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    CertWorkItemDto dto = rowModel.getObject();
                    return dto.getCampaignStageNumber() + "/" + dto.getCampaignStageCount();
                }
            }));
            String stageName = rowModel.getObject().getCurrentStageName();
            if (stageName != null) {
                item.add(AttributeModifier.replace("title", stageName));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    column = new AbstractColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.escalation")) {

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
            item.add(new Label(componentId, new AbstractReadOnlyModel<String>() {

                @Override
                public String getObject() {
                    CertWorkItemDto dto = rowModel.getObject();
                    Integer n = dto.getEscalationLevelNumber();
                    return n != null ? String.valueOf(n) : null;
                }
            }));
            String info = rowModel.getObject().getEscalationLevelInfo();
            if (info != null) {
                item.add(AttributeModifier.replace("title", info));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.requested"), SearchingUtils.CURRENT_REVIEW_REQUESTED_TIMESTAMP, CertWorkItemDto.F_REVIEW_REQUESTED) {

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, IModel<CertWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            CertWorkItemDto dto = rowModel.getObject();
            Date started = dto.getStageStarted();
            if (started != null) {
                item.add(AttributeModifier.replace("title", WebComponentUtil.getLocalizedDate(started, DateLabelComponent.LONG_MEDIUM_STYLE)));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    column = new PropertyColumn<CertWorkItemDto, String>(createStringResource("PageCertDecisions.table.deadline"), SearchingUtils.CURRENT_REVIEW_DEADLINE, CertWorkItemDto.F_DEADLINE_AS_STRING) {

        @Override
        public void populateItem(Item<ICellPopulator<CertWorkItemDto>> item, String componentId, final IModel<CertWorkItemDto> rowModel) {
            super.populateItem(item, componentId, rowModel);
            XMLGregorianCalendar deadline = rowModel.getObject().getCertCase().getCurrentStageDeadline();
            if (deadline != null) {
                item.add(AttributeModifier.replace("title", WebComponentUtil.formatDate(deadline)));
                item.add(new TooltipBehavior());
            }
        }
    };
    columns.add(column);
    final AvailableResponses availableResponses = new AvailableResponses(getPage());
    final int responses = availableResponses.getResponseKeys().size();
    column = new MultiButtonColumn<CertWorkItemDto>(new Model(), responses + 1) {

        @Override
        public String getCaption(int id) {
            return availableResponses.getCaption(id);
        }

        @Override
        public boolean isButtonEnabled(int id, IModel<CertWorkItemDto> model) {
            if (id < responses) {
                return !decisionEquals(model, availableResponses.getResponseValues().get(id));
            } else {
                return false;
            }
        }

        @Override
        public boolean isButtonVisible(int id, IModel<CertWorkItemDto> model) {
            if (id < responses) {
                return true;
            } else {
                return !availableResponses.isAvailable(model.getObject().getResponse());
            }
        }

        @Override
        public String getButtonColorCssClass(int id) {
            if (id < responses) {
                return getDecisionButtonColor(getRowModel(), availableResponses.getResponseValues().get(id));
            } else {
                return BUTTON_COLOR_CLASS.DANGER.toString();
            }
        }

        @Override
        public void clickPerformed(int id, AjaxRequestTarget target, IModel<CertWorkItemDto> model) {
            if (id < responses) {
                // should be always the case
                recordActionPerformed(target, model.getObject(), availableResponses.getResponseValues().get(id));
            }
        }
    };
    columns.add(column);
    column = new DirectlyEditablePropertyColumn<CertWorkItemDto>(createStringResource("PageCertDecisions.table.comment"), CertWorkItemDto.F_COMMENT) {

        @Override
        public void onBlur(AjaxRequestTarget target, IModel model) {
            // TODO determine somehow if the model.comment was really changed
            recordActionPerformed(target, (CertWorkItemDto) model.getObject(), null);
        }
    };
    columns.add(column);
    columns.add(new InlineMenuHeaderColumn(createInlineMenu(availableResponses)));
    return columns;
}
Also used : ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AvailableResponses(com.evolveum.midpoint.web.page.admin.certification.helpers.AvailableResponses) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) CertWorkItemDto(com.evolveum.midpoint.web.page.admin.certification.dto.CertWorkItemDto) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType) IModel(org.apache.wicket.model.IModel) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) Date(java.util.Date) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model)

Example 34 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class CertCaseOrWorkItemDto method computeDeadlineAsString.

private String computeDeadlineAsString(PageBase page) {
    XMLGregorianCalendar deadline = certCase.getCurrentStageDeadline();
    if (deadline == null) {
        return "";
    } else {
        long delta = XmlTypeConverter.toMillis(deadline) - System.currentTimeMillis();
        // round to hours; we always round down
        // 1 hour
        long precision = 3600000L;
        if (Math.abs(delta) > precision) {
            delta = (delta / precision) * precision;
        }
        //todo i18n
        if (delta > 0) {
            return PageBase.createStringResourceStatic(page, "PageCert.in", DurationFormatUtils.formatDurationWords(delta, true, true)).getString();
        } else if (delta < 0) {
            return PageBase.createStringResourceStatic(page, "PageCert.ago", DurationFormatUtils.formatDurationWords(-delta, true, true)).getString();
        } else {
            return page.getString("PageCert.now");
        }
    }
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar)

Example 35 with XMLGregorianCalendar

use of javax.xml.datatype.XMLGregorianCalendar in project midpoint by Evolveum.

the class TestParseGenericObject method assertGenericObject.

private void assertGenericObject(PrismObject<GenericObjectType> generic) throws DatatypeConfigurationException {
    generic.checkConsistence();
    assertEquals("Wrong oid", "c0c010c0-d34d-b33f-f00d-999111111111", generic.getOid());
    //		assertEquals("Wrong version", "42", resource.getVersion());
    PrismObjectDefinition<GenericObjectType> resourceDefinition = generic.getDefinition();
    assertNotNull("No resource definition", resourceDefinition);
    PrismAsserts.assertObjectDefinition(resourceDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "genericObject"), GenericObjectType.COMPLEX_TYPE, GenericObjectType.class);
    assertEquals("Wrong class in resource", GenericObjectType.class, generic.getCompileTimeClass());
    GenericObjectType genericType = generic.asObjectable();
    assertNotNull("asObjectable resulted in null", genericType);
    assertPropertyValue(generic, "name", PrismTestUtil.createPolyString("My Sample Config Object"));
    assertPropertyDefinition(generic, "name", PolyStringType.COMPLEX_TYPE, 0, 1);
    assertPropertyValue(generic, "objectType", QNameUtil.qNameToUri(new QName(SchemaTestConstants.NS_EXTENSION, "SampleConfigType")));
    assertPropertyDefinition(generic, "objectType", DOMUtil.XSD_ANYURI, 1, 1);
    PrismContainer<?> extensionContainer = generic.findContainer(GenericObjectType.F_EXTENSION);
    assertContainerDefinition(extensionContainer, "extension", ExtensionType.COMPLEX_TYPE, 0, 1);
    PrismContainerDefinition<?> extensionContainerDefinition = extensionContainer.getDefinition();
    assertTrue("Extension container definition is NOT dynamic", extensionContainerDefinition.isDynamic());
    PrismContainerValue<?> extensionContainerValue = extensionContainer.getValue();
    List<Item<?, ?>> extensionItems = extensionContainerValue.getItems();
    assertEquals("Wrong number of extension items", 5, extensionItems.size());
    // COMPLEX RUN TIME PROPERTIES...NOT SUPPORTED WITH NEW PARSERS..
    //		Item<?> locationsItem = extensionContainerValue.findItem(SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT);
    //		if (!(locationsItem instanceof PrismProperty)) {
    //			AssertJUnit.fail("Expected the extension item to be of type "+PrismProperty.class+
    //					"but it was of type "+locationsItem.getClass());
    //		}
    //		PrismProperty<?> locationsProperty = (PrismProperty<?>)locationsItem;
    //		assertEquals("Wrong name of <locations>", SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT, locationsProperty.getElementName());
    //		PrismPropertyDefinition locationsDefinition = locationsProperty.getDefinition();
    //		assertNotNull("No definition for <locations>", locationsDefinition);
    //		PrismAsserts.assertDefinition(locationsDefinition, SchemaTestConstants.EXTENSION_LOCATIONS_ELEMENT, 
    //				SchemaTestConstants.EXTENSION_LOCATIONS_TYPE, 0, -1);
    PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_STRING_TYPE_ELEMENT, "X marks the spot");
    PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_INT_TYPE_ELEMENT, 1234);
    PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_DOUBLE_TYPE_ELEMENT, 456.789D);
    PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_LONG_TYPE_ELEMENT, 567890L);
    XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar("2002-05-30T09:10:11");
    PrismAsserts.assertPropertyValue(extensionContainerValue, SchemaTestConstants.EXTENSION_DATE_TYPE_ELEMENT, calendar);
}
Also used : GenericObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.GenericObjectType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) QName(javax.xml.namespace.QName)

Aggregations

XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)336 Test (org.testng.annotations.Test)159 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)130 Task (com.evolveum.midpoint.task.api.Task)104 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)72 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)52 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)44 Date (java.util.Date)36 TestValidityRecomputeTask (com.evolveum.midpoint.model.intest.sync.TestValidityRecomputeTask)32 ArrayList (java.util.ArrayList)32 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)31 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)31 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)30 AbstractSynchronizationStoryTest (com.evolveum.midpoint.model.intest.sync.AbstractSynchronizationStoryTest)23 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)21 GregorianCalendar (java.util.GregorianCalendar)18 QName (javax.xml.namespace.QName)18 DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)15 Duration (javax.xml.datatype.Duration)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)14