Search in sources :

Example 61 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ScheduleAuditLogSupportImpl method doCreate.

private void doCreate(final CreateScheduledJobParams params, final ScheduledJob job, final Context rootContext) {
    final PropertyTree data = new PropertyTree();
    final PropertySet paramsSet = data.addSet("params");
    final PropertySet resultSet = data.addSet("result");
    addParams(paramsSet, params);
    addResult(resultSet, job);
    log("system.job.create", data, job.getName(), rootContext);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 62 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ScheduleAuditLogSupportImpl method doDelete.

private void doDelete(final ScheduledJobName name, final boolean result, final Context rootContext) {
    final PropertyTree data = new PropertyTree();
    final PropertySet paramsSet = data.addSet("params");
    final PropertySet resultSet = data.addSet("result");
    paramsSet.addString("name", name.getValue());
    resultSet.addString("name", name.getValue());
    resultSet.addBoolean("value", result);
    log("system.job.delete", data, name, rootContext);
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 63 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class SchedulerServiceActivatorTest method mockNode.

private void mockNode(final CreateScheduledJobParams params) {
    final PropertyTree jobData = new PropertyTree();
    final PropertySet calendar = new PropertySet();
    calendar.addString(ScheduledJobPropertyNames.CALENDAR_TYPE, params.getCalendar().getType().name());
    calendar.addString(ScheduledJobPropertyNames.CALENDAR_VALUE, ((CronCalendar) params.getCalendar()).getCronValue());
    calendar.addString(ScheduledJobPropertyNames.CALENDAR_TIMEZONE, ((CronCalendar) params.getCalendar()).getTimeZone().getID());
    jobData.addString(ScheduledJobPropertyNames.DESCRIPTOR, params.getDescriptor().toString());
    jobData.addBoolean(ScheduledJobPropertyNames.ENABLED, params.isEnabled());
    jobData.addSet(ScheduledJobPropertyNames.CALENDAR, calendar);
    jobData.addSet(ScheduledJobPropertyNames.CONFIG, params.getConfig().getRoot().copy(jobData));
    jobData.setString(ScheduledJobPropertyNames.CREATOR, "user:system:creator");
    jobData.setString(ScheduledJobPropertyNames.MODIFIER, "user:system:creator");
    jobData.setString(ScheduledJobPropertyNames.CREATED_TIME, "2016-11-02T10:36:00Z");
    jobData.setString(ScheduledJobPropertyNames.MODIFIED_TIME, "2016-11-02T10:36:00Z");
    final Node job = Node.create().id(NodeId.from("abc")).name(params.getName().getValue()).parentPath(NodePath.ROOT).data(jobData).build();
    when(nodeService.create(isA(CreateNodeParams.class))).thenReturn(job);
}
Also used : CronCalendar(com.enonic.xp.scheduler.CronCalendar) PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) PropertySet(com.enonic.xp.data.PropertySet) CreateNodeParams(com.enonic.xp.node.CreateNodeParams)

Example 64 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class UpdateLastRunCommandTest method mockNode.

private Node mockNode() {
    final PropertyTree jobData = new PropertyTree();
    final PropertySet calendar = new PropertySet();
    calendar.addString(ScheduledJobPropertyNames.CALENDAR_TYPE, "ONE_TIME");
    calendar.addString(ScheduledJobPropertyNames.CALENDAR_VALUE, "2021-02-25T10:44:33.170079900Z");
    jobData.addString(ScheduledJobPropertyNames.DESCRIPTOR, "app:key");
    jobData.addBoolean(ScheduledJobPropertyNames.ENABLED, true);
    jobData.addSet(ScheduledJobPropertyNames.CALENDAR, calendar);
    jobData.addSet(ScheduledJobPropertyNames.CONFIG, new PropertySet());
    jobData.setString(ScheduledJobPropertyNames.CREATOR, "user:system:creator");
    jobData.setString(ScheduledJobPropertyNames.MODIFIER, "user:system:modifier");
    jobData.setString(ScheduledJobPropertyNames.CREATED_TIME, "2021-02-26T10:44:33.170079900Z");
    jobData.setString(ScheduledJobPropertyNames.MODIFIED_TIME, "2021-03-26T10:44:33.170079900Z");
    return Node.create().id(NodeId.from("abc")).name("test").parentPath(NodePath.ROOT).data(jobData).build();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 65 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ScheduleAuditLogSupportImpl method addCalendar.

private void addCalendar(final PropertySet targetSet, final ScheduleCalendar calendar) {
    final PropertySet calendarSet = new PropertySet();
    switch(calendar.getType()) {
        case CRON:
            final CronCalendar cronCalendar = ((CronCalendar) calendar);
            calendarSet.setString(ScheduledJobPropertyNames.CALENDAR_VALUE, cronCalendar.getCronValue());
            calendarSet.setString(ScheduledJobPropertyNames.CALENDAR_TIMEZONE, cronCalendar.getTimeZone().getID());
            calendarSet.setString(ScheduledJobPropertyNames.CALENDAR_TYPE, ScheduleCalendarType.CRON.name());
            break;
        case ONE_TIME:
            final OneTimeCalendar oneTimeCalendar = ((OneTimeCalendar) calendar);
            calendarSet.setString(ScheduledJobPropertyNames.CALENDAR_VALUE, oneTimeCalendar.getValue().toString());
            calendarSet.setString(ScheduledJobPropertyNames.CALENDAR_TYPE, ScheduleCalendarType.ONE_TIME.name());
            break;
        default:
            throw new IllegalStateException(String.format("invalid calendar type: '%s'", calendar.getType()));
    }
    targetSet.setSet(ScheduledJobPropertyNames.CALENDAR, calendarSet);
}
Also used : CronCalendar(com.enonic.xp.scheduler.CronCalendar) OneTimeCalendar(com.enonic.xp.scheduler.OneTimeCalendar) PropertySet(com.enonic.xp.data.PropertySet)

Aggregations

PropertySet (com.enonic.xp.data.PropertySet)225 PropertyTree (com.enonic.xp.data.PropertyTree)150 Test (org.junit.jupiter.api.Test)69 Content (com.enonic.xp.content.Content)30 Node (com.enonic.xp.node.Node)20 CreateContentParams (com.enonic.xp.content.CreateContentParams)12 ContentId (com.enonic.xp.content.ContentId)11 Property (com.enonic.xp.data.Property)11 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)10 PrincipalKey (com.enonic.xp.security.PrincipalKey)9 ContentQuery (com.enonic.xp.content.ContentQuery)7 DescriptorKey (com.enonic.xp.page.DescriptorKey)7 ExtraDatas (com.enonic.xp.content.ExtraDatas)6 Form (com.enonic.xp.form.Form)6 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)6 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)5 ContentPropertyNames (com.enonic.xp.content.ContentPropertyNames)5 ExtraData (com.enonic.xp.content.ExtraData)5 PropertyPath (com.enonic.xp.data.PropertyPath)5 Page (com.enonic.xp.page.Page)5