use of org.craftercms.studio.api.v1.to.DmDependencyTO in project studio by craftercms.
the class WorkflowServiceImpl method handleReferences.
protected void handleReferences(String site, SubmitPackage submitpackage, DmDependencyTO dmDependencyTO, boolean isNotScheduled, SubmitPackage dependencyPackage, String approver, Set<String> rescheduledUris, Set<String> processedUris) {
if (!processedUris.contains(dmDependencyTO.getUri())) {
ItemMetadata properties = objectMetadataManager.getProperties(site, dmDependencyTO.getUri());
ZonedDateTime scheduledDate = null;
if (properties != null) {
scheduledDate = properties.getLaunchDate();
}
ItemState state = objectStateService.getObjectState(site, dmDependencyTO.getUri());
if (state != null) {
if (!State.isSubmitted(State.valueOf(state.getState())) && scheduledDate != null && scheduledDate.equals(dmDependencyTO.getScheduledDate())) {
if (objectStateService.isScheduled(site, dmDependencyTO.getUri())) {
return;
} else {
submitpackage.addToPackage(dmDependencyTO);
}
}
}
if (!dmDependencyTO.isReference()) {
submitpackage.addToPackage(dmDependencyTO);
}
if (isRescheduleRequest(dmDependencyTO, site)) {
rescheduledUris.add(dmDependencyTO.getUri());
}
processedUris.add(dmDependencyTO.getUri());
}
}
use of org.craftercms.studio.api.v1.to.DmDependencyTO in project studio by craftercms.
the class WorkflowServiceImpl method getRefAndChildOfDiffDateFromParent_new.
protected List<DmDependencyTO> getRefAndChildOfDiffDateFromParent_new(String site, List<DmDependencyTO> submittedItems, boolean removeInPages) {
List<DmDependencyTO> childAndReferences = new ArrayList<>();
for (DmDependencyTO submittedItem : submittedItems) {
List<DmDependencyTO> children = submittedItem.getChildren();
ZonedDateTime date = submittedItem.getScheduledDate();
if (children != null) {
Iterator<DmDependencyTO> childItr = children.iterator();
while (childItr.hasNext()) {
DmDependencyTO child = childItr.next();
ZonedDateTime pageDate = child.getScheduledDate();
if ((date == null && pageDate != null) || (date != null && !date.equals(pageDate))) {
if (!submittedItem.isNow()) {
child.setNow(false);
if (date != null && (pageDate != null && pageDate.isBefore(date))) {
child.setScheduledDate(date);
}
}
childAndReferences.add(child);
List<DmDependencyTO> childDeps = child.flattenChildren();
for (DmDependencyTO childDep : childDeps) {
if (objectStateService.isUpdatedOrNew(site, childDep.getUri())) {
childAndReferences.add(childDep);
}
}
child.setReference(false);
childItr.remove();
if (removeInPages) {
String uri = child.getUri();
List<DmDependencyTO> pages = submittedItem.getPages();
if (pages != null) {
Iterator<DmDependencyTO> pagesIter = pages.iterator();
while (pagesIter.hasNext()) {
DmDependencyTO page = pagesIter.next();
if (page.getUri().equals(uri)) {
pagesIter.remove();
}
}
}
}
}
}
}
}
return childAndReferences;
}
use of org.craftercms.studio.api.v1.to.DmDependencyTO in project studio by craftercms.
the class WorkflowServiceImpl method addDependenciesForSubmittedItems.
protected List<DmDependencyTO> addDependenciesForSubmittedItems(String site, List<DmDependencyTO> submittedItems, SimpleDateFormat format, String globalScheduledDate) throws ServiceLayerException {
List<DmDependencyTO> dependencies = new ArrayList<DmDependencyTO>();
Set<String> dependenciesPaths = new HashSet<String>();
for (DmDependencyTO submittedItem : submittedItems) {
if (!dependenciesPaths.contains(submittedItem.getUri())) {
dependenciesPaths.addAll(dependencyService.getPublishingDependencies(site, submittedItem.getUri()));
}
}
for (String depPath : dependenciesPaths) {
dependencies.add(getSubmittedItem_new(site, depPath, format, globalScheduledDate));
}
return dependencies;
}
use of org.craftercms.studio.api.v1.to.DmDependencyTO in project studio by craftercms.
the class WorkflowServiceImpl method resolveSubmittedPaths.
protected void resolveSubmittedPaths(String site, DmDependencyTO item, List<String> submittedPaths, Set<String> processedPaths) throws ServiceLayerException {
if (!processedPaths.contains(item.getUri())) {
if (!submittedPaths.contains(item.getUri())) {
submittedPaths.add(item.getUri());
}
List<DmDependencyTO> children = item.getChildren();
if (children != null) {
for (DmDependencyTO child : children) {
if (objectStateService.isUpdatedOrNew(site, child.getUri())) {
if (!submittedPaths.contains(child.getUri())) {
submittedPaths.add(child.getUri());
}
resolveSubmittedPaths(site, child, submittedPaths, processedPaths);
}
}
}
List<String> dependencyPaths = dependencyService.getPublishingDependencies(site, item.getUri());
submittedPaths.addAll(dependencyPaths);
processedPaths.addAll(dependencyPaths);
processedPaths.add(item.getUri());
}
}
use of org.craftercms.studio.api.v1.to.DmDependencyTO in project studio by craftercms.
the class WorkflowServiceImpl method getChildrenForRenamedItem.
protected List<DmDependencyTO> getChildrenForRenamedItem(String site, DmDependencyTO renameItem) {
List<DmDependencyTO> toRet = new ArrayList<>();
List<DmDependencyTO> children = renameItem.getChildren();
ZonedDateTime date = renameItem.getScheduledDate();
if (children != null) {
Iterator<DmDependencyTO> childItr = children.iterator();
while (childItr.hasNext()) {
DmDependencyTO child = childItr.next();
ZonedDateTime pageDate = child.getScheduledDate();
if ((date == null && pageDate != null) || (date != null && !date.equals(pageDate))) {
if (!renameItem.isNow()) {
child.setNow(false);
if (date != null && (pageDate != null && pageDate.isBefore(date))) {
child.setScheduledDate(date);
}
}
toRet.add(child);
List<DmDependencyTO> childDeps = child.flattenChildren();
for (DmDependencyTO childDep : childDeps) {
if (objectStateService.isUpdatedOrNew(site, childDep.getUri())) {
toRet.add(childDep);
}
}
child.setReference(false);
childItr.remove();
}
}
}
return toRet;
}
Aggregations