* trunk/ccm-cms/src/com/arsdigita/cms/installer/xml/ContentTypeHelperImpl.java
trunk/ccm-cms/src/com/arsdigita/cms/ContentType.java Vererbungshierarchien werden jetzt korrekt in die content_types Tabelle eingetragen * releases/1.1.2/ccm-zes-aplaws/bundles/devel/cfg/applications.cfg ccm-sci-types-organizationwithpublications hinzugefügt * trunk/ccm-cms/src/com/arsdigita/cms/ui/ItemSearchFolderBrowser.java trunk/ccm-cms/src/com/arsdigita/cms/Folder.java Sortierung im ItemSearchWidget korrigiert. Könnte aber eventuell Seiteneffekte an anderen Stellen haben (bisher keine gefunden). git-svn-id: https://svn.libreccm.org/ccm/trunk@960 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
b51c08c90b
commit
a62873c8e9
|
|
@ -408,6 +408,10 @@ public class ContentType extends ACSObject {
|
||||||
*/
|
*/
|
||||||
public void addDescendants(BigDecimal newDescendant) {
|
public void addDescendants(BigDecimal newDescendant) {
|
||||||
|
|
||||||
|
if (getID().equals(newDescendant)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Get the list of descendants from db
|
// Get the list of descendants from db
|
||||||
String descendants = (String) get(DESCENDANTS);
|
String descendants = (String) get(DESCENDANTS);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -630,7 +630,7 @@ public class Folder extends ContentItem {
|
||||||
public ItemCollection(DataQuery query) {
|
public ItemCollection(DataQuery query) {
|
||||||
super(new DataQueryDataCollectionAdapter(doAlias(query), ITEM));
|
super(new DataQueryDataCollectionAdapter(doAlias(query), ITEM));
|
||||||
|
|
||||||
init(query, true);
|
init(query, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(DataQuery query, boolean bSort) {
|
private void init(DataQuery query, boolean bSort) {
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,15 @@ import com.arsdigita.persistence.metadata.ObjectType;
|
||||||
import com.arsdigita.search.MetadataProviderRegistry;
|
import com.arsdigita.search.MetadataProviderRegistry;
|
||||||
import com.arsdigita.util.Assert;
|
import com.arsdigita.util.Assert;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public class ContentTypeHelperImpl implements ContentTypeHelper {
|
public class ContentTypeHelperImpl implements ContentTypeHelper {
|
||||||
|
|
||||||
private static final Logger s_log = Logger.getLogger(ContentTypeHelperImpl.class);
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
ContentTypeHelperImpl.class);
|
||||||
private ContentType m_type;
|
private ContentType m_type;
|
||||||
private ContentType m_parent;
|
private ContentType m_parent;
|
||||||
// Basic Content type properties
|
// Basic Content type properties
|
||||||
|
|
@ -194,16 +197,16 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
|
||||||
try {
|
try {
|
||||||
s_log.debug("making new content type");
|
s_log.debug("making new content type");
|
||||||
m_type =
|
m_type =
|
||||||
ContentType.findByAssociatedObjectType(m_objectType);
|
ContentType.findByAssociatedObjectType(m_objectType);
|
||||||
m_type.setLabel(m_label);
|
m_type.setLabel(m_label);
|
||||||
m_type.setDescription(m_description);
|
m_type.setDescription(m_description);
|
||||||
m_type.save();
|
m_type.save();
|
||||||
} catch (DataObjectNotFoundException e) {
|
} catch (DataObjectNotFoundException e) {
|
||||||
s_log.debug("Looking for content type");
|
s_log.debug("Looking for content type");
|
||||||
s_log.debug("Creating ContentType Label: " + m_label
|
s_log.debug("Creating ContentType Label: " + m_label
|
||||||
+ " Description: " + m_description
|
+ " Description: " + m_description
|
||||||
+ " className: " + m_className
|
+ " className: " + m_className
|
||||||
+ " AssociatedObjectType: " + m_objectType);
|
+ " AssociatedObjectType: " + m_objectType);
|
||||||
|
|
||||||
// this is what would need to be changed to make the
|
// this is what would need to be changed to make the
|
||||||
// label and description multi-lingual. To do that,
|
// label and description multi-lingual. To do that,
|
||||||
|
|
@ -223,11 +226,12 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Turn on search indexing for this type
|
// Turn on search indexing for this type
|
||||||
ObjectType type = SessionManager.getMetadataRoot().getObjectType(m_objectType);
|
ObjectType type = SessionManager.getMetadataRoot().getObjectType(
|
||||||
|
m_objectType);
|
||||||
if (type.isSubtypeOf(ContentPage.BASE_DATA_OBJECT_TYPE)
|
if (type.isSubtypeOf(ContentPage.BASE_DATA_OBJECT_TYPE)
|
||||||
&& !isInternal()) {
|
&& !isInternal()) {
|
||||||
s_log.debug("Registering search adapter for "
|
s_log.debug("Registering search adapter for "
|
||||||
+ m_objectType);
|
+ m_objectType);
|
||||||
MetadataProviderRegistry.registerAdapter(
|
MetadataProviderRegistry.registerAdapter(
|
||||||
m_objectType,
|
m_objectType,
|
||||||
new ContentPageMetadataProvider());
|
new ContentPageMetadataProvider());
|
||||||
|
|
@ -253,7 +257,7 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
|
||||||
while (ac.next()) {
|
while (ac.next()) {
|
||||||
AuthoringStep step = ac.getAuthoringStep();
|
AuthoringStep step = ac.getAuthoringStep();
|
||||||
s_log.debug("Deleting authoringStep "
|
s_log.debug("Deleting authoringStep "
|
||||||
+ step.getLabel());
|
+ step.getLabel());
|
||||||
m_kit.removeStep(step);
|
m_kit.removeStep(step);
|
||||||
step.delete();
|
step.delete();
|
||||||
}
|
}
|
||||||
|
|
@ -274,25 +278,25 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
public void addAuthoringStep(String label,
|
public void addAuthoringStep(String label,
|
||||||
String description,
|
String description,
|
||||||
String component,
|
String component,
|
||||||
BigDecimal ordering) {
|
BigDecimal ordering) {
|
||||||
addAuthoringStep(label, null, description, null, component, ordering);
|
addAuthoringStep(label, null, description, null, component, ordering);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addAuthoringStep(String labelKey,
|
public void addAuthoringStep(String labelKey,
|
||||||
String labelBundle,
|
String labelBundle,
|
||||||
String descriptionKey,
|
String descriptionKey,
|
||||||
String descriptionBundle,
|
String descriptionBundle,
|
||||||
String component,
|
String component,
|
||||||
BigDecimal ordering) {
|
BigDecimal ordering) {
|
||||||
s_log.debug("Creating AuthoringStep "
|
s_log.debug("Creating AuthoringStep "
|
||||||
+ " LabelKey: " + labelKey
|
+ " LabelKey: " + labelKey
|
||||||
+ " LabelBundle: " + labelBundle
|
+ " LabelBundle: " + labelBundle
|
||||||
+ " DescriptionKey: " + descriptionKey
|
+ " DescriptionKey: " + descriptionKey
|
||||||
+ " DescriptionBundle: " + descriptionBundle
|
+ " DescriptionBundle: " + descriptionBundle
|
||||||
+ " Component " + component
|
+ " Component " + component
|
||||||
+ " Ordering: " + ordering);
|
+ " Ordering: " + ordering);
|
||||||
|
|
||||||
Assert.exists(m_kit);
|
Assert.exists(m_kit);
|
||||||
Assert.exists(labelKey);
|
Assert.exists(labelKey);
|
||||||
|
|
@ -301,8 +305,8 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
|
||||||
Assert.exists(ordering);
|
Assert.exists(ordering);
|
||||||
|
|
||||||
m_kit.createStep(labelKey, labelBundle,
|
m_kit.createStep(labelKey, labelBundle,
|
||||||
descriptionKey, descriptionBundle,
|
descriptionKey, descriptionBundle,
|
||||||
component, ordering);
|
component, ordering);
|
||||||
m_kit.save();
|
m_kit.save();
|
||||||
m_type.save();
|
m_type.save();
|
||||||
}
|
}
|
||||||
|
|
@ -318,8 +322,13 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
|
||||||
*/
|
*/
|
||||||
private void createPedigree(ContentType type) {
|
private void createPedigree(ContentType type) {
|
||||||
|
|
||||||
|
//System.out.printf(String.format(
|
||||||
|
// "\n\nCreating pedigrees for content type '%s'...\n",
|
||||||
|
// type.getClassName()));
|
||||||
|
|
||||||
// The parent content type
|
// The parent content type
|
||||||
ContentType parent = null;
|
ContentType parent = null;
|
||||||
|
List<ContentType> parents = new ArrayList<ContentType> ();
|
||||||
|
|
||||||
// Get all content types
|
// Get all content types
|
||||||
ContentTypeCollection cts = ContentType.getAllContentTypes();
|
ContentTypeCollection cts = ContentType.getAllContentTypes();
|
||||||
|
|
@ -329,31 +338,51 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
|
||||||
while (cts.next()) {
|
while (cts.next()) {
|
||||||
ContentType ct = cts.getContentType();
|
ContentType ct = cts.getContentType();
|
||||||
|
|
||||||
|
//System.out.printf(
|
||||||
|
// "Checking if content type '%s' is a sub type of content type '%s'\n",
|
||||||
|
//type.getClassName(),
|
||||||
|
//ct.getClassName());
|
||||||
try {
|
try {
|
||||||
Class.forName(type.getClassName()).asSubclass(Class.forName(ct.getClassName()));
|
Class.forName(type.getClassName()).asSubclass(Class.forName(ct.
|
||||||
|
getClassName()));
|
||||||
|
//System.out.printf(
|
||||||
|
// "content type '%s' is a sub type of content type '%s'\n",
|
||||||
|
// type.getClassName(),
|
||||||
|
// ct.getClassName());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// This cast is not valid so type is not a sublacss of ct
|
// This cast is not valid so type is not a sublacss of ct
|
||||||
|
//System.out.printf(
|
||||||
|
//"content type '%s' is *NOT* a sub type of content type '%s'\n",
|
||||||
|
//type.getClassName(),
|
||||||
|
//ct.getClassName());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the current ct as possible parent if we haven't found any parent yet
|
// Save the current ct as possible parent if we haven't found any parent yet
|
||||||
// or if the current ancestor list is longer than that one from the possible
|
// or if the current ancestor list is longer than that one from the possible
|
||||||
// parent earlier found
|
// parent earlier found
|
||||||
if (!type.getClassName().equals(ct.getClassName())
|
if (!(type.getClassName().equals(ct.getClassName()))
|
||||||
&& (parent == null
|
&& (parent == null
|
||||||
|| (parent.getAncestors() != null
|
|| (parent.getAncestors() != null
|
||||||
&& ct.getAncestors() != null
|
&& ct.getAncestors() != null
|
||||||
&& parent.getAncestors().length() < ct.getAncestors().length()))) {
|
&& parent.getAncestors().length() < ct.getAncestors().
|
||||||
parent = ct;
|
length())
|
||||||
|
|| !(parent.getClassName().equals(ct.getClassName())))) {
|
||||||
|
//System.out.printf("Setting parent to '%s'...\n",
|
||||||
|
//ct.getClassName());
|
||||||
|
parent = ct;
|
||||||
|
parents.add(ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is a valid parent content type create the pedigree
|
// If there is a valid parent content type create the pedigree
|
||||||
if (parent != null && !parent.getClassName().equals(type.getClassName())) {
|
if (parent != null && !parent.getClassName().equals(type.getClassName())) {
|
||||||
|
//System.out.printf("Setting ancestors...\n");
|
||||||
if (parent.getAncestors() != null) {
|
if (parent.getAncestors() != null) {
|
||||||
String parentAncestors = parent.getAncestors();
|
String parentAncestors = parent.getAncestors();
|
||||||
|
|
||||||
StringTokenizer strTok = new StringTokenizer(parentAncestors, "/");
|
StringTokenizer strTok = new StringTokenizer(parentAncestors,
|
||||||
|
"/");
|
||||||
|
|
||||||
// Add parent ancestors to this content types ancestor list
|
// Add parent ancestors to this content types ancestor list
|
||||||
// Also while we iterate through the list, we also need to add
|
// Also while we iterate through the list, we also need to add
|
||||||
|
|
@ -369,16 +398,29 @@ public class ContentTypeHelperImpl implements ContentTypeHelper {
|
||||||
// The db is broken. There is no content type for this ID
|
// The db is broken. There is no content type for this ID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//System.out.printf("Adding ancestor '%s'\n", ctID.toString());
|
||||||
// Add parent ancestor
|
// Add parent ancestor
|
||||||
type.addAncestor(ctID);
|
type.addAncestor(ctID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add parent to ancestor list
|
// Add parent to ancestor list
|
||||||
|
//System.out.printf(
|
||||||
|
// "Adding parent '%s' to ancestor list of content type '%s'...\n",
|
||||||
|
// parent.getClassName(), type.getClassName());
|
||||||
type.addAncestor(parent.getID());
|
type.addAncestor(parent.getID());
|
||||||
|
|
||||||
// Add this to parent descendants
|
// Add this to parent descendants
|
||||||
parent.addDescendants(type.getID());
|
// //System.out.printf("Adding '%s' to descendants of parent '%s'...\n",
|
||||||
|
// type.getClassName(), parent.getClassName());
|
||||||
|
// parent.addDescendants(type.getID());
|
||||||
|
for(ContentType p: parents) {
|
||||||
|
parent.addDescendants(type.getID());
|
||||||
|
//System.out.printf("Adding '%s' to descendants of parent '%s'...\n",
|
||||||
|
// type.getClassName(), p.getClassName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
//System.out.printf("Finished create pedigree for content type '%s'.\n\n",
|
||||||
|
// type.getClassName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -222,14 +222,14 @@ public class ItemSearchFolderBrowser extends Table {
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// WTF? The selected content type does not exist in the table???
|
// WTF? The selected content type does not exist in the table???
|
||||||
}
|
}
|
||||||
|
|
||||||
itemColl.addFilter(or);
|
itemColl.addFilter(or);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemColl.addOrder("isFolder desc");
|
itemColl.addOrder("isFolder desc");
|
||||||
itemColl.addOrder("lower(item."
|
itemColl.addOrder("lower(item." + ContentItem.NAME + ") ");
|
||||||
+ ContentItem.NAME + ") ");
|
|
||||||
return itemColl;
|
return itemColl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -361,6 +361,7 @@ public class ItemSearchFolderBrowser extends Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean nextRow() {
|
public boolean nextRow() {
|
||||||
|
System.out.println("test");
|
||||||
return m_itemColl != null ? m_itemColl.next() : false;
|
return m_itemColl != null ? m_itemColl.next() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue