本文整理汇总了Java中org.alfresco.service.cmr.action.scheduled.SchedulableAction.IntervalPeriod类的典型用法代码示例。如果您正苦于以下问题:Java IntervalPeriod类的具体用法?Java IntervalPeriod怎么用?Java IntervalPeriod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntervalPeriod类属于org.alfresco.service.cmr.action.scheduled.SchedulableAction包,在下文中一共展示了IntervalPeriod类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCreation
import org.alfresco.service.cmr.action.scheduled.SchedulableAction.IntervalPeriod; //导入依赖的package包/类
/**
* Tests that we can create, save, edit, delete etc the scheduled persisted actions
*/
public void testCreation()
{
ScheduledPersistedAction schedule = service.createSchedule(testAction);
assertNotNull(schedule);
assertTrue(testAction == schedule.getAction());
assertEquals(testAction.getNodeRef(), schedule.getAction().getNodeRef());
assertNull(schedule.getScheduleStart());
assertNull(schedule.getScheduleInterval());
assertNull(schedule.getScheduleIntervalCount());
assertNull(schedule.getScheduleIntervalPeriod());
Date now = new Date();
schedule.setScheduleStart(now);
assertEquals(now, schedule.getScheduleStart());
schedule.setScheduleIntervalCount(2);
assertEquals(new Integer(2), schedule.getScheduleIntervalCount());
schedule.setScheduleIntervalPeriod(ScheduledPersistedAction.IntervalPeriod.Day);
assertEquals(ScheduledPersistedAction.IntervalPeriod.Day, schedule.getScheduleIntervalPeriod());
}
示例2: testCreation
import org.alfresco.service.cmr.action.scheduled.SchedulableAction.IntervalPeriod; //导入依赖的package包/类
/**
* Tests that we can create, save, edit, delete etc the scheduled persisted
* actions
*/
public void testCreation()
{
ScheduledPersistedAction schedule = service.createSchedule(testAction);
assertNotNull(schedule);
assertTrue(testAction == schedule.getAction());
assertEquals(testAction.getNodeRef(), schedule.getAction().getNodeRef());
assertNull(schedule.getScheduleStart());
assertNull(schedule.getScheduleInterval());
assertNull(schedule.getScheduleIntervalCount());
assertNull(schedule.getScheduleIntervalPeriod());
Date now = new Date();
schedule.setScheduleStart(now);
assertEquals(now, schedule.getScheduleStart());
schedule.setScheduleIntervalCount(2);
assertEquals(new Integer(2), schedule.getScheduleIntervalCount());
schedule
.setScheduleIntervalPeriod(ScheduledPersistedAction.IntervalPeriod.Day);
assertEquals(ScheduledPersistedAction.IntervalPeriod.Day, schedule
.getScheduleIntervalPeriod());
}
示例3: loadPersistentSchedule
import org.alfresco.service.cmr.action.scheduled.SchedulableAction.IntervalPeriod; //导入依赖的package包/类
protected ScheduledPersistedActionImpl loadPersistentSchedule(NodeRef schedule)
{
if (!nodeService.exists(schedule))
return null;
// create action
Action action = null;
AssociationRef actionAssoc = findActionAssociationFromSchedule(schedule);
if (actionAssoc != null)
{
action = runtimeActionService.createAction(actionAssoc.getTargetRef());
}
// create schedule
ScheduledPersistedActionImpl scheduleImpl = new ScheduledPersistedActionImpl(action);
scheduleImpl.setPersistedAtNodeRef(schedule);
scheduleImpl.setScheduleLastExecutedAt((Date)nodeService.getProperty(schedule, ActionModel.PROP_LAST_EXECUTED_AT));
scheduleImpl.setScheduleStart((Date)nodeService.getProperty(schedule, ActionModel.PROP_START_DATE));
scheduleImpl.setScheduleIntervalCount((Integer)nodeService.getProperty(schedule, ActionModel.PROP_INTERVAL_COUNT));
String period = (String)nodeService.getProperty(schedule, ActionModel.PROP_INTERVAL_PERIOD);
if (period != null)
{
scheduleImpl.setScheduleIntervalPeriod(IntervalPeriod.valueOf(period));
}
return scheduleImpl;
}
示例4: updatePersistentSchedule
import org.alfresco.service.cmr.action.scheduled.SchedulableAction.IntervalPeriod; //导入依赖的package包/类
private void updatePersistentSchedule(ScheduledPersistedActionImpl schedule)
{
NodeRef nodeRef = schedule.getPersistedAtNodeRef();
if (nodeRef == null)
throw new IllegalStateException("Must be persisted first");
// update schedule properties
nodeService.setProperty(nodeRef, ActionModel.PROP_START_DATE, schedule.getScheduleStart());
nodeService.setProperty(nodeRef, ActionModel.PROP_INTERVAL_COUNT, schedule.getScheduleIntervalCount());
IntervalPeriod period = schedule.getScheduleIntervalPeriod();
nodeService.setProperty(nodeRef, ActionModel.PROP_INTERVAL_PERIOD, period == null ? null : period.name());
// We don't save the last executed at date here, that only gets changed
// from within the execution loop
// update scheduled action (represented as an association)
// NOTE: can only associate to a single action from a schedule (as specified by the action model)
// update association to reflect updated schedule
AssociationRef actionAssoc = findActionAssociationFromSchedule(nodeRef);
NodeRef actionNodeRef = schedule.getActionNodeRef();
try
{
behaviourFilter.disableBehaviour(ActionModel.TYPE_ACTION_SCHEDULE);
if (actionNodeRef == null)
{
if (actionAssoc != null)
{
// remove associated action
nodeService.removeAssociation(actionAssoc.getSourceRef(), actionAssoc.getTargetRef(), actionAssoc.getTypeQName());
}
}
else
{
if (actionAssoc == null)
{
// create associated action
nodeService.createAssociation(nodeRef, actionNodeRef, ActionModel.ASSOC_SCHEDULED_ACTION);
}
else if (!actionAssoc.getTargetRef().equals(actionNodeRef))
{
// associated action has changed... first remove existing association
nodeService.removeAssociation(actionAssoc.getSourceRef(), actionAssoc.getTargetRef(), actionAssoc.getTypeQName());
nodeService.createAssociation(nodeRef, actionNodeRef, ActionModel.ASSOC_SCHEDULED_ACTION);
}
}
}
finally
{
behaviourFilter.enableBehaviour(ActionModel.TYPE_ACTION_SCHEDULE);
}
}
示例5: testCreateSaveLoad
import org.alfresco.service.cmr.action.scheduled.SchedulableAction.IntervalPeriod; //导入依赖的package包/类
public void testCreateSaveLoad() throws Exception
{
// create and save schedule
ScheduledPersistedAction schedule = service.createSchedule(testAction);
assertNotNull(schedule);
Date now = new Date();
schedule.setScheduleStart(now);
schedule.setScheduleIntervalCount(2);
schedule.setScheduleIntervalPeriod(ScheduledPersistedAction.IntervalPeriod.Day);
assertNull(((ScheduledPersistedActionImpl) schedule).getPersistedAtNodeRef());
service.saveSchedule(schedule);
assertNotNull(((ScheduledPersistedActionImpl) schedule).getPersistedAtNodeRef());
// Load it again, should have the same details still
ScheduledPersistedAction retrieved = serviceImpl
.loadPersistentSchedule(((ScheduledPersistedActionImpl) schedule).getPersistedAtNodeRef());
assertNotNull(retrieved);
assertEquals(testAction.getNodeRef(), retrieved.getAction().getNodeRef());
assertEquals(now, retrieved.getScheduleStart());
assertEquals(new Integer(2), retrieved.getScheduleIntervalCount());
assertEquals(ScheduledPersistedAction.IntervalPeriod.Day, retrieved.getScheduleIntervalPeriod());
assertNotNull(((ScheduledPersistedActionImpl) schedule).getPersistedAtNodeRef());
// Load a 2nd copy, won't be any changes
ScheduledPersistedAction second = serviceImpl.loadPersistentSchedule(((ScheduledPersistedActionImpl) schedule)
.getPersistedAtNodeRef());
assertNotNull(second);
assertEquals(testAction.getNodeRef(), second.getAction().getNodeRef());
assertEquals(now, second.getScheduleStart());
assertEquals(new Integer(2), second.getScheduleIntervalCount());
assertEquals(ScheduledPersistedAction.IntervalPeriod.Day, second.getScheduleIntervalPeriod());
// Now ensure we can create for an action that didn't have a noderef
// when we started
schedule = service.createSchedule(testAction3);
assertNull(schedule.getActionNodeRef());
assertNull(((ScheduledPersistedActionImpl) schedule).getPersistedAtNodeRef());
runtimeActionService.createActionNodeRef(testAction3, serviceImpl.SCHEDULED_ACTION_ROOT_NODE_REF,
ContentModel.ASSOC_CONTAINS, QName.createQName("TestAction3"));
assertNotNull(schedule.getActionNodeRef());
assertNull(((ScheduledPersistedActionImpl) schedule).getPersistedAtNodeRef());
service.saveSchedule(schedule);
assertNotNull(schedule.getActionNodeRef());
assertNotNull(((ScheduledPersistedActionImpl) schedule).getPersistedAtNodeRef());
}
示例6: updateDefinitionProperties
import org.alfresco.service.cmr.action.scheduled.SchedulableAction.IntervalPeriod; //导入依赖的package包/类
/**
* Updates properties on the definition, based on the JSON.
* Doesn't save the definition
* Doesn't change the name
*/
protected void updateDefinitionProperties(ReplicationDefinition replicationDefinition, JSONObject json)
throws JSONException
{
if(json.has("description")) {
String description = json.getString("description");
replicationDefinition.setDescription(description);
}
if(json.has("targetName")) {
String targetName = json.getString("targetName");
replicationDefinition.setTargetName(targetName);
}
if(json.has("enabled")) {
boolean enabled = json.getBoolean("enabled");
replicationDefinition.setEnabled(enabled);
}
if(json.has("payload")) {
replicationDefinition.getPayload().clear();
JSONArray payload = json.getJSONArray("payload");
for(int i=0; i<payload.length(); i++) {
String node = payload.getString(i);
replicationDefinition.getPayload().add(
new NodeRef(node)
);
}
}
// Now for the scheduling parts
if(json.has("schedule") && !json.isNull("schedule")) {
// Turn on scheduling, if not already enabled
replicationService.enableScheduling(replicationDefinition);
// Update the properties
JSONObject schedule = json.getJSONObject("schedule");
if(schedule.has("start") && !schedule.isNull("start")) {
// Look for start:.... or start:{"iso8601":....}
String startDate = schedule.getString("start");
if(schedule.get("start") instanceof JSONObject) {
startDate = schedule.getJSONObject("start").getString("iso8601");
}
replicationDefinition.setScheduleStart( ISO8601DateFormat.parse(startDate) );
} else {
replicationDefinition.setScheduleStart(null);
}
if(schedule.has("intervalPeriod") && !schedule.isNull("intervalPeriod")) {
replicationDefinition.setScheduleIntervalPeriod(
IntervalPeriod.valueOf(schedule.getString("intervalPeriod"))
);
} else {
replicationDefinition.setScheduleIntervalPeriod(null);
}
if(schedule.has("intervalCount") && !schedule.isNull("intervalCount")) {
replicationDefinition.setScheduleIntervalCount(
schedule.getInt("intervalCount")
);
} else {
replicationDefinition.setScheduleIntervalCount(null);
}
} else {
// Disable scheduling
replicationService.disableScheduling(replicationDefinition);
}
}
示例7: testCreateSaveLoad
import org.alfresco.service.cmr.action.scheduled.SchedulableAction.IntervalPeriod; //导入依赖的package包/类
public void testCreateSaveLoad() throws Exception
{
// create and save schedule
ScheduledPersistedAction schedule = service.createSchedule(testAction);
assertNotNull(schedule);
Date now = new Date();
schedule.setScheduleStart(now);
schedule.setScheduleIntervalCount(2);
schedule
.setScheduleIntervalPeriod(ScheduledPersistedAction.IntervalPeriod.Day);
assertNull(
((ScheduledPersistedActionImpl) schedule).getPersistedAtNodeRef()
);
service.saveSchedule(schedule);
assertNotNull(((ScheduledPersistedActionImpl) schedule)
.getPersistedAtNodeRef());
// Load it again, should have the same details still
ScheduledPersistedAction retrieved = serviceImpl
.loadPersistentSchedule(((ScheduledPersistedActionImpl) schedule)
.getPersistedAtNodeRef());
assertNotNull(retrieved);
assertEquals(testAction.getNodeRef(), retrieved.getAction().getNodeRef());
assertEquals(now, retrieved.getScheduleStart());
assertEquals(new Integer(2), retrieved.getScheduleIntervalCount());
assertEquals(ScheduledPersistedAction.IntervalPeriod.Day, retrieved
.getScheduleIntervalPeriod());
assertNotNull(((ScheduledPersistedActionImpl) schedule)
.getPersistedAtNodeRef());
// Load a 2nd copy, won't be any changes
ScheduledPersistedAction second = serviceImpl
.loadPersistentSchedule(((ScheduledPersistedActionImpl) schedule)
.getPersistedAtNodeRef());
assertNotNull(second);
assertEquals(testAction.getNodeRef(), second.getAction().getNodeRef());
assertEquals(now, second.getScheduleStart());
assertEquals(new Integer(2), second.getScheduleIntervalCount());
assertEquals(ScheduledPersistedAction.IntervalPeriod.Day, second
.getScheduleIntervalPeriod());
// Now ensure we can create for an action that didn't have a noderef
// when we started
schedule = service.createSchedule(testAction3);
assertNull(schedule.getActionNodeRef());
assertNull(((ScheduledPersistedActionImpl) schedule)
.getPersistedAtNodeRef());
runtimeActionService.createActionNodeRef(
testAction3, serviceImpl.SCHEDULED_ACTION_ROOT_NODE_REF,
ContentModel.ASSOC_CONTAINS, QName.createQName("TestAction3"));
assertNotNull(schedule.getActionNodeRef());
assertNull(((ScheduledPersistedActionImpl) schedule)
.getPersistedAtNodeRef());
service.saveSchedule(schedule);
assertNotNull(schedule.getActionNodeRef());
assertNotNull(((ScheduledPersistedActionImpl) schedule)
.getPersistedAtNodeRef());
}