ContentType
* public static ContentTypeCollection getSiblingsOf(ContentType ct) hinzugefügt, aber noch nicht getestet. Evt. funktioniert der Filter noch nicht richtig. git-svn-id: https://svn.libreccm.org/ccm/trunk@563 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
57c8e789a5
commit
d539eae18c
|
|
@ -21,10 +21,12 @@ package com.arsdigita.cms;
|
||||||
import com.arsdigita.domain.DataObjectNotFoundException;
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
import com.arsdigita.formbuilder.PersistentForm;
|
import com.arsdigita.formbuilder.PersistentForm;
|
||||||
import com.arsdigita.kernel.ACSObject;
|
import com.arsdigita.kernel.ACSObject;
|
||||||
|
import com.arsdigita.persistence.CompoundFilter;
|
||||||
import com.arsdigita.persistence.DataCollection;
|
import com.arsdigita.persistence.DataCollection;
|
||||||
import com.arsdigita.persistence.DataObject;
|
import com.arsdigita.persistence.DataObject;
|
||||||
import com.arsdigita.persistence.DataQuery;
|
import com.arsdigita.persistence.DataQuery;
|
||||||
import com.arsdigita.persistence.DataQueryDataCollectionAdapter;
|
import com.arsdigita.persistence.DataQueryDataCollectionAdapter;
|
||||||
|
import com.arsdigita.persistence.FilterFactory;
|
||||||
import com.arsdigita.persistence.OID;
|
import com.arsdigita.persistence.OID;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
import com.arsdigita.persistence.SessionManager;
|
||||||
import com.arsdigita.util.UncheckedWrapperException;
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
|
@ -38,6 +40,7 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>A Content Type defines the characteristics of a content
|
* <p>A Content Type defines the characteristics of a content
|
||||||
|
|
@ -457,35 +460,17 @@ public class ContentType extends ACSObject {
|
||||||
ContentTypeCollection types = getAllContentTypes();
|
ContentTypeCollection types = getAllContentTypes();
|
||||||
types.addFilter("associatedObjectType = :type").set("type", objType);
|
types.addFilter("associatedObjectType = :type").set("type", objType);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (types.next()) {
|
if (types.next()) {
|
||||||
ContentType type = types.getContentType();
|
ContentType type = types.getContentType();
|
||||||
types.close();
|
types.close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// no match
|
// no match
|
||||||
types.close();
|
types.close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
throw new DataObjectNotFoundException(
|
throw new DataObjectNotFoundException(
|
||||||
"No matching content type for object type " + objType);
|
"No matching content type for object type " + objType);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -497,10 +482,6 @@ public class ContentType extends ACSObject {
|
||||||
*/
|
*/
|
||||||
public static ContentTypeCollection getAllContentTypes() {
|
public static ContentTypeCollection getAllContentTypes() {
|
||||||
return getAllContentTypes(true);
|
return getAllContentTypes(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -510,35 +491,20 @@ public class ContentType extends ACSObject {
|
||||||
*/
|
*/
|
||||||
public static ContentTypeCollection getUserDefinedContentTypes() {
|
public static ContentTypeCollection getUserDefinedContentTypes() {
|
||||||
return getAllContentTypes(false);
|
return getAllContentTypes(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param internal If true, fetch all content types, including internal
|
* @param internal If true, fetch all content types, including internal
|
||||||
* content types. If false, only fetch all user-defined content types.
|
* content types.
|
||||||
*/
|
*/
|
||||||
private static ContentTypeCollection getAllContentTypes(boolean internal) {
|
private static ContentTypeCollection getAllContentTypes(boolean internal) {
|
||||||
DataCollection da = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
|
DataCollection da = SessionManager.getSession().retrieve(BASE_DATA_OBJECT_TYPE);
|
||||||
ContentTypeCollection types = new ContentTypeCollection(da);
|
ContentTypeCollection types = new ContentTypeCollection(da);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!internal) {
|
if (!internal) {
|
||||||
types.addFilter("isInternal = '0'");
|
types.addFilter("isInternal = '0'");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return types;
|
return types;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -551,17 +517,40 @@ public class ContentType extends ACSObject {
|
||||||
final String query = "com.arsdigita.cms.registeredContentTypes";
|
final String query = "com.arsdigita.cms.registeredContentTypes";
|
||||||
DataQuery dq = SessionManager.getSession().retrieveQuery(query);
|
DataQuery dq = SessionManager.getSession().retrieveQuery(query);
|
||||||
DataCollection dc = new DataQueryDataCollectionAdapter(dq, "type");
|
DataCollection dc = new DataQueryDataCollectionAdapter(dq, "type");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return new ContentTypeCollection(dc);
|
return new ContentTypeCollection(dc);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private static List s_xsl = new ArrayList();
|
|
||||||
|
public static ContentTypeCollection getSiblingsOf(ContentType ct) {
|
||||||
|
// final String query = "com.arsdigita.cms.registeredContentTypes";
|
||||||
|
// DataQuery dq = SessionManager.getSession().retrieveQuery(query);
|
||||||
|
// DataCollection dc = new DataQueryDataCollectionAdapter(dq, "type");
|
||||||
|
// return new ContentTypeCollection(dc);
|
||||||
|
ContentTypeCollection ctc = ContentType.getRegisteredContentTypes();
|
||||||
|
|
||||||
|
// The Filter Factory
|
||||||
|
FilterFactory ff = ctc.getFilterFactory();
|
||||||
|
|
||||||
|
// Create an or-filter
|
||||||
|
CompoundFilter or = ff.or();
|
||||||
|
|
||||||
|
// The content type must be either of the requested type
|
||||||
|
or.addFilter(ff.equals(ContentType.ID, ct.ID));
|
||||||
|
|
||||||
|
// Or must be a sibling of the requested type
|
||||||
|
try {
|
||||||
|
StringTokenizer strTok = new StringTokenizer(ct.getSiblings(), "/");
|
||||||
|
while (strTok.hasMoreElements()) {
|
||||||
|
or.addFilter(ff.equals(ContentType.ID, (String) strTok.nextElement()));
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// WTF? The selected content type does not exist in the table???
|
||||||
|
}
|
||||||
|
|
||||||
|
ctc.addFilter(or);
|
||||||
|
return ctc;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List s_xsl = new ArrayList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NB this interface is liable to change.
|
* NB this interface is liable to change.
|
||||||
|
|
@ -573,10 +562,6 @@ public class ContentType extends ACSObject {
|
||||||
public static void registerXSLFile(ContentType type,
|
public static void registerXSLFile(ContentType type,
|
||||||
String path) {
|
String path) {
|
||||||
s_xsl.add(new XSLEntry(type, path));
|
s_xsl.add(new XSLEntry(type, path));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -589,10 +574,6 @@ public class ContentType extends ACSObject {
|
||||||
public static void unregisterXSLFile(ContentType type,
|
public static void unregisterXSLFile(ContentType type,
|
||||||
String path) {
|
String path) {
|
||||||
s_xsl.remove(new XSLEntry(type, path));
|
s_xsl.remove(new XSLEntry(type, path));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -601,22 +582,6 @@ public class ContentType extends ACSObject {
|
||||||
*/
|
*/
|
||||||
public static Iterator getXSLFileURLs() {
|
public static Iterator getXSLFileURLs() {
|
||||||
return new EntryIterator(s_xsl.iterator());
|
return new EntryIterator(s_xsl.iterator());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EntryIterator implements Iterator {
|
private static class EntryIterator implements Iterator {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue