use of org.compiere.model.MContainer in project adempiere by adempiere.
the class WebProjectDeploy method doIt.
// prepare
/**
* Process
* @return info
* @throws Exception
*/
protected String doIt() throws Exception {
org.compiere.cm.CacheHandler thisHandler = new org.compiere.cm.CacheHandler(org.compiere.cm.CacheHandler.convertJNPURLToCacheURL(getCtx().getProperty("java.naming.provider.url")), log, getCtx(), get_TrxName());
log.info("CM_WebProject_ID=" + p_CM_WebProject_ID);
m_project = new MWebProject(getCtx(), p_CM_WebProject_ID, get_TrxName());
if (m_project.get_ID() != p_CM_WebProject_ID)
throw new AdempiereUserError("@NotFound@ @CM_WebProject_ID@ " + p_CM_WebProject_ID);
// Deploy Media
MMedia[] media = MMedia.getMedia(m_project);
MMediaServer[] mserver = MMediaServer.getMediaServer(m_project);
for (int i = 0; i < mserver.length; i++) mserver[i].deploy(media);
// Stage
MCStage[] stages = MCStage.getStages(m_project);
for (int i = 0; i < stages.length; i++) m_map.put(new Integer(stages[i].getCM_CStage_ID()), stages[i]);
// Copy Stage Tree
MTree treeS = new MTree(getCtx(), m_project.getAD_TreeCMS_ID(), false, false, get_TrxName());
MTreeNode root = treeS.getRoot();
copyStage(root, "/");
// Delete Inactive Containers
MContainer[] containers = MContainer.getContainers(m_project);
for (int i = 0; i < containers.length; i++) {
MContainer container = containers[i];
if (!m_idList.contains(new Integer(container.getCM_Container_ID()))) {
String name = container.getName();
if (container.delete(true))
log.fine("Deleted: " + name);
else // e.g. was referenced
{
log.warning("Failed Delete: " + name);
addLog(0, null, null, "@Error@ @Delete@: " + name);
}
}
// Remove Container from cache
thisHandler.cleanContainer(container.get_ID());
}
// Delete Inactive
// Sync Stage & Container Tree
MTree_NodeCMS[] nodesCMS = MTree_NodeCMS.getTree(getCtx(), m_project.getAD_TreeCMS_ID(), get_TrxName());
MTree_NodeCMC[] nodesCMC = MTree_NodeCMC.getTree(getCtx(), m_project.getAD_TreeCMC_ID(), get_TrxName());
for (int s = 0; s < nodesCMS.length; s++) {
MTree_NodeCMS nodeCMS = nodesCMS[s];
int Node_ID = nodeCMS.getNode_ID();
for (int c = 0; c < nodesCMC.length; c++) {
MTree_NodeCMC nodeCMC = nodesCMC[c];
if (nodeCMC.getNode_ID() == Node_ID) {
//if (nodeCMS.getParent_ID()!=0)
nodeCMC.setParent_ID(nodeCMS.getParent_ID());
nodeCMC.setSeqNo(nodeCMS.getSeqNo());
nodeCMC.saveEx();
break;
}
}
}
// for all stage nodes
// Clean ContainerTree Cache
thisHandler.cleanContainerTree(p_CM_WebProject_ID);
return "@Copied@ @CM_Container_ID@ #" + m_idList.size();
}
use of org.compiere.model.MContainer in project adempiere by adempiere.
the class TreeXML method appendNode.
private String appendNode(MTreeNode thisNode) {
StringBuffer tempTree = new StringBuffer();
Integer ID = new Integer(thisNode.getNode_ID());
MContainer container = m_map.get(ID);
//
int size = thisNode.getChildCount();
for (int i = 0; i < size; i++) {
MTreeNode child = (MTreeNode) thisNode.getChildAt(i);
ID = new Integer(child.getNode_ID());
container = m_map.get(ID);
if (container == null) {
continue;
}
if (!container.isActive())
continue;
//
tempTree.append("<treenode>");
tempTree.append("<CM_Container_ID>" + container.get_ID() + "</CM_Container_ID>");
tempTree.append("<Name>" + container.getName() + "</Name>");
tempTree.append("<Title>" + container.getTitle() + "</Title>");
tempTree.append("<RelativeURL>" + container.getRelativeURL() + "</RelativeURL>");
tempTree.append("<Description>" + container.getDescription() + "</Description>");
tempTree.append("<children>" + child.getChildCount() + "</children>");
xmlContainer = container.get_xmlString(xmlContainer);
if (child.isSummary())
tempTree.append(appendNode(child));
tempTree.append("</treenode>");
}
return tempTree.toString();
}
use of org.compiere.model.MContainer in project adempiere by adempiere.
the class WebProjectDeploy method copyStage.
// doIt
/**
* Copy Stage
* @param node node
* @param path path
*/
private void copyStage(MTreeNode node, String path) {
org.compiere.cm.CacheHandler thisHandler = new org.compiere.cm.CacheHandler(org.compiere.cm.CacheHandler.convertJNPURLToCacheURL(getCtx().getProperty("java.naming.provider.url")), log, getCtx(), get_TrxName());
Integer ID = new Integer(node.getNode_ID());
MCStage stage = m_map.get(ID);
//
int size = node.getChildCount();
for (int i = 0; i < size; i++) {
MTreeNode child = (MTreeNode) node.getChildAt(i);
ID = new Integer(child.getNode_ID());
stage = m_map.get(ID);
if (stage == null) {
log.warning("Not Found ID=" + ID);
continue;
}
if (!stage.isActive())
continue;
//
if (stage != null && stage.isModified()) {
MContainer cc = MContainer.copy(m_project, stage, path);
if (cc != null) {
addLog(0, null, null, "@Copied@: " + cc.getName());
m_idList.add(ID);
}
// Remove Container from cache
thisHandler.cleanContainer(cc.get_ID());
// Reset Modified flag...
stage.setIsModified(false);
stage.save(stage.get_TrxName());
}
if (child.isSummary())
copyStage(child, path + stage.getRelativeURL() + "/");
}
}
use of org.compiere.model.MContainer in project adempiere by adempiere.
the class KIndexRerun method doIt.
// prepare
/**
* Perform process.
* @return Message (clear text)
* @throws Exception if not successful
*/
protected String doIt() throws Exception {
// ReIndex Container
int[] containers = MContainer.getAllIDs("CM_Container", "CM_WebProject_ID=" + p_CM_WebProject_ID, get_TrxName());
for (int i = 0; i < containers.length; i++) {
MContainer thisContainer = new MContainer(getCtx(), containers[i], get_TrxName());
thisContainer.reIndex(false);
}
// ReIndex News
int[] newsChannels = MNewsChannel.getAllIDs("CM_NewsChannel", "CM_WebProject_ID=" + p_CM_WebProject_ID, get_TrxName());
for (int i = 0; i < newsChannels.length; i++) {
MNewsChannel thisChannel = new MNewsChannel(getCtx(), newsChannels[i], get_TrxName());
thisChannel.reIndex(false);
int[] newsItems = MNewsItem.getAllIDs("CM_NewsItem", "CM_NewsChannel_ID=" + newsChannels[i], get_TrxName());
for (int k = 0; k < newsItems.length; k++) {
MNewsItem thisItem = new MNewsItem(getCtx(), newsItems[k], get_TrxName());
thisItem.reIndex(false);
}
}
return "finished...";
}
use of org.compiere.model.MContainer in project adempiere by adempiere.
the class Container method getCM_Container.
/**
* Get Container from cache by ID
* @param ID Container ID
* @param CM_WebProject_ID Web Project
* @return Container
*/
public MContainer getCM_Container(int ID, int CM_WebProject_ID) {
if (cache.containsKey(ID)) {
use(ID);
return (MContainer) cache.get(ID);
} else {
MContainer thisContainer = MContainer.get(ctx, ID, CM_WebProject_ID, "WebCM");
if (thisContainer == null) {
return getCM_ContainerByURL("/error404.html", CM_WebProject_ID, true);
} else {
put("" + thisContainer.getCM_Container_ID(), thisContainer);
cacheContainerURL.put(CM_WebProject_ID + "-" + thisContainer.getRelativeURL(), "" + thisContainer.getCM_Container_ID());
return thisContainer;
}
}
}
Aggregations