- Erster Teil des neuen Module ccm-sci-types-organizationwithpublications

git-svn-id: https://svn.libreccm.org/ccm/trunk@952 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2011-06-05 19:56:02 +00:00
parent a83b943274
commit 3669e85d11
46 changed files with 557 additions and 2033 deletions

View File

@ -400,6 +400,29 @@ public class ContentItem extends VersionedACSObject implements CustomCopy {
super.set(key, value); super.set(key, value);
} }
/**
* Public add for use by metadata forms.
*
* @param propertyName
* @param dobj
* @return
*/
@Override
public DataObject add(String propertyName, DomainObject dobj) {
return super.add(propertyName, dobj);
}
/**
* Public remove for use by metadata forms
*
* @param propertyName
* @param dobj
*/
@Override
public void remove(String propertyName, DomainObject dobj) {
super.remove(propertyName, dobj);
}
/** /**
* For new content items, sets the associated content type if it * For new content items, sets the associated content type if it
* has not been already set. * has not been already set.

View File

@ -43,7 +43,6 @@ import org.apache.log4j.Logger;
class DataObjectImpl implements DataObject { class DataObjectImpl implements DataObject {
final static Logger s_log = Logger.getLogger(DataObjectImpl.class); final static Logger s_log = Logger.getLogger(DataObjectImpl.class);
private Session m_ssn; private Session m_ssn;
private OID m_oid; private OID m_oid;
private List m_observers = new ArrayList(); private List m_observers = new ArrayList();
@ -53,10 +52,9 @@ class DataObjectImpl implements DataObject {
private boolean m_valid = true; private boolean m_valid = true;
// originating transaction has terminated // originating transaction has terminated
private boolean m_transactionDone = false; private boolean m_transactionDone = false;
// package-scoped, written and read by Session // package-scoped, written and read by Session
PropertyMap p_pMap; PropertyMap p_pMap;
// package-scoped, read/written by Session // package-scoped, read/written by Session
com.redhat.persistence.metadata.ObjectType p_objectType; com.redhat.persistence.metadata.ObjectType p_objectType;
private final class ObserverEntry { private final class ObserverEntry {
@ -85,7 +83,7 @@ class DataObjectImpl implements DataObject {
// unschedule event from others // unschedule event from others
if (isWaiting(event)) { if (isWaiting(event)) {
for (Iterator it = m_waiting.entrySet().iterator(); for (Iterator it = m_waiting.entrySet().iterator();
it.hasNext(); ) { it.hasNext();) {
Map.Entry me = (Map.Entry) it.next(); Map.Entry me = (Map.Entry) it.next();
DataEvent value = (DataEvent) me.getValue(); DataEvent value = (DataEvent) me.getValue();
if (value.equals(event)) { if (value.equals(event)) {
@ -100,7 +98,9 @@ class DataObjectImpl implements DataObject {
} }
public void scheduleEvent(DataEvent now, DataEvent waiting) { public void scheduleEvent(DataEvent now, DataEvent waiting) {
if (!isFiring(waiting)) { m_waiting.put(now, waiting); } if (!isFiring(waiting)) {
m_waiting.put(now, waiting);
}
} }
public DataEvent clearFiring(DataEvent event) { public DataEvent clearFiring(DataEvent event) {
@ -124,7 +124,6 @@ class DataObjectImpl implements DataObject {
public String toString() { public String toString() {
return "Observer: " + m_observer; return "Observer: " + m_observer;
} }
} }
DataObjectImpl(ObjectType type) { DataObjectImpl(ObjectType type) {
@ -143,9 +142,9 @@ class DataObjectImpl implements DataObject {
// disconnected data objects should use the session of the current // disconnected data objects should use the session of the current
// thread // thread
if (isDisconnected()) { if (isDisconnected()) {
throw new IllegalStateException throw new IllegalStateException(
("There was an error in disconnected object implementation. " "There was an error in disconnected object implementation. "
+ "Disconnected data object can not access session."); + "Disconnected data object can not access session.");
} }
// this checks that nondisconnected objects are not being used // this checks that nondisconnected objects are not being used
@ -156,10 +155,10 @@ class DataObjectImpl implements DataObject {
&& m_ssn != null && m_ssn != null
&& SessionManager.getSession() != null && SessionManager.getSession() != null
&& m_ssn != SessionManager.getSession().getProtoSession()) { && m_ssn != SessionManager.getSession().getProtoSession()) {
throw new PersistenceException throw new PersistenceException("This data object: (" + this
("This data object: (" + this + ") is being accessed from " + ") is being accessed from "
+ "another thread before its originating transaction has " + "another thread before its originating transaction has "
+ "terminated."); + "terminated.");
} }
return m_ssn; return m_ssn;
@ -188,13 +187,26 @@ class DataObjectImpl implements DataObject {
validate(); validate();
Property prop = getObjectType().getProperty(property); Property prop = getObjectType().getProperty(property);
if (prop == null) { if (prop == null) {
throw new PersistenceException StringBuilder builder = new StringBuilder();
("no such property: " + property + " for " + this); Iterator properties = getObjectType().getProperties();
while (properties.hasNext()) {
if (builder.length() > 0) {
builder.append(", ");
}
builder.append(((Property) properties.next()).getName());
}
throw new PersistenceException(String.format(
"no such property: %s for %s. Available properties: %s",
property.toString(),
this.toString(),
builder.toString()));
} }
if (prop.isCollection()) { if (prop.isCollection()) {
if (isDisconnected()) { if (isDisconnected()) {
return new DataAssociationImpl return new DataAssociationImpl(SessionManager.getSession(), this,
(SessionManager.getSession(), this, prop); prop);
} else { } else {
return new DataAssociationImpl(getSession(), this, prop); return new DataAssociationImpl(getSession(), this, prop);
} }
@ -222,8 +234,8 @@ class DataObjectImpl implements DataObject {
DataObjectImpl dobj = (DataObjectImpl) obj; DataObjectImpl dobj = (DataObjectImpl) obj;
dobj.disconnect(); dobj.disconnect();
if (!dobj.isValid()) { if (!dobj.isValid()) {
throw new IllegalStateException throw new IllegalStateException("got invalid data object from session: "
("got invalid data object from session: " + obj); + obj);
} }
} }
m_disconnect.put(prop, obj); m_disconnect.put(prop, obj);
@ -244,10 +256,14 @@ class DataObjectImpl implements DataObject {
} }
private void doDisconnect() { private void doDisconnect() {
if (m_disconnect != null) { return; } if (m_disconnect != null) {
return;
}
m_disconnect = new HashMap(); m_disconnect = new HashMap();
// access the session directly as part of disconnection // access the session directly as part of disconnection
if (m_ssn.isDeleted(this)) { return; } if (m_ssn.isDeleted(this)) {
return;
}
if (!m_manualDisconnect) { if (!m_manualDisconnect) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("autodisconnect: " + getOID(), new Throwable()); s_log.debug("autodisconnect: " + getOID(), new Throwable());
@ -255,10 +271,11 @@ class DataObjectImpl implements DataObject {
} }
com.redhat.persistence.Session ssn = com.redhat.persistence.Session ssn =
SessionManager.getSession().getProtoSession(); SessionManager.getSession().
getProtoSession();
for (Iterator it = getObjectType().getProperties(); for (Iterator it = getObjectType().getProperties();
it.hasNext(); ) { it.hasNext();) {
Property p = (Property) it.next(); Property p = (Property) it.next();
if (!p.isCollection() if (!p.isCollection()
&& !p.isKeyProperty() && !p.isKeyProperty()
@ -274,12 +291,14 @@ class DataObjectImpl implements DataObject {
public void set(String property, Object value) { public void set(String property, Object value) {
validateWrite(); validateWrite();
// all entry points for empty strings need to be converted to null // all entry points for empty strings need to be converted to null
if ("".equals(value)) { value = null; } if ("".equals(value)) {
value = null;
}
try { try {
Property prop = getObjectType().getProperty(property); Property prop = getObjectType().getProperty(property);
if (prop == null) { if (prop == null) {
throw new PersistenceException throw new PersistenceException("no such property: " + property
("no such property: " + property + " for " + this); + " for " + this);
} }
if (prop.isKeyProperty()) { if (prop.isKeyProperty()) {
m_oid.set(property, value); m_oid.set(property, value);
@ -296,21 +315,27 @@ class DataObjectImpl implements DataObject {
public boolean isNew() { public boolean isNew() {
validate(); validate();
if (isDisconnected()) { return false; } if (isDisconnected()) {
return false;
}
// handle calls to isNew before key is set // handle calls to isNew before key is set
return !m_oid.isInitialized() || return !m_oid.isInitialized() || (getSsn().isNew(this) && !getSsn().
(getSsn().isNew(this) && !getSsn().isPersisted(this)); isPersisted(this));
} }
public boolean isDeleted() { public boolean isDeleted() {
validate(); validate();
if (isDisconnected()) { return false; } if (isDisconnected()) {
return false;
}
return getSsn().isDeleted(this); return getSsn().isDeleted(this);
} }
public boolean isCommitted() { public boolean isCommitted() {
validate(); validate();
if (isDisconnected()) { return false; } if (isDisconnected()) {
return false;
}
return m_oid.isInitialized() && !getSsn().isNew(this); return m_oid.isInitialized() && !getSsn().isNew(this);
} }
@ -319,7 +344,9 @@ class DataObjectImpl implements DataObject {
} }
void invalidate(boolean connectedOnly, boolean error) { void invalidate(boolean connectedOnly, boolean error) {
if (!isValid()) { return; } if (!isValid()) {
return;
}
// access the session directly as part of disconnection // access the session directly as part of disconnection
if (error || (!connectedOnly && m_ssn.isModified(this))) { if (error || (!connectedOnly && m_ssn.isModified(this))) {
@ -336,8 +363,8 @@ class DataObjectImpl implements DataObject {
public void disconnect() { public void disconnect() {
if (!m_oid.isInitialized()) { if (!m_oid.isInitialized()) {
throw new PersistenceException throw new PersistenceException("can't disconnect uninitialized: "
("can't disconnect uninitialized: " + this); + this);
} }
m_manualDisconnect = true; m_manualDisconnect = true;
@ -346,13 +373,17 @@ class DataObjectImpl implements DataObject {
public boolean isModified() { public boolean isModified() {
validate(); validate();
if (isDisconnected()) { return false; } if (isDisconnected()) {
return false;
}
return !getSsn().isFlushed(this); return !getSsn().isFlushed(this);
} }
public boolean isPropertyModified(String name) { public boolean isPropertyModified(String name) {
validate(); validate();
if (isDisconnected()) { return false; } if (isDisconnected()) {
return false;
}
return !getSsn().isFlushed(this, convert(name)); return !getSsn().isFlushed(this, convert(name));
} }
@ -369,8 +400,8 @@ class DataObjectImpl implements DataObject {
private void validate() { private void validate() {
if (!isValid()) { if (!isValid()) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug s_log.debug("invalid data object invalidated at: ",
("invalid data object invalidated at: ", m_invalidStack); m_invalidStack);
} }
throw new PersistenceException("invalid data object: " + this); throw new PersistenceException("invalid data object: " + this);
} }
@ -379,8 +410,8 @@ class DataObjectImpl implements DataObject {
private void validateWrite() { private void validateWrite() {
validate(); validate();
if (isDisconnected()) { if (isDisconnected()) {
throw new PersistenceException throw new PersistenceException("can not write to disconnected data object: "
("can not write to disconnected data object: " + this); + this);
} }
} }
@ -398,7 +429,7 @@ class DataObjectImpl implements DataObject {
public void specialize(String subtypeName) { public void specialize(String subtypeName) {
validate(); validate();
ObjectType subtype = ObjectType subtype =
getSession().getMetadataRoot().getObjectType(subtypeName); getSession().getMetadataRoot().getObjectType(subtypeName);
if (subtype == null) { if (subtype == null) {
throw new PersistenceException("No such type: " + subtypeName); throw new PersistenceException("No such type: " + subtypeName);
@ -442,9 +473,10 @@ class DataObjectImpl implements DataObject {
private void assertFlushed() { private void assertFlushed() {
// m_ssn.assertFlushed(this) doesn't work because of '~' properties // m_ssn.assertFlushed(this) doesn't work because of '~' properties
for (Iterator it = getObjectType().getProperties(); for (Iterator it = getObjectType().getProperties();
it.hasNext(); ) { it.hasNext();) {
Property p = (Property) it.next(); Property p = (Property) it.next();
s_log.debug(String.format("Asserting that property '%s' is flushed...", p.getName())); s_log.debug(String.format(
"Asserting that property '%s' is flushed...", p.getName()));
if (!getSsn().isFlushed(this, C.prop(m_ssn.getRoot(), p))) { if (!getSsn().isFlushed(this, C.prop(m_ssn.getRoot(), p))) {
// use m_ssn to generate the exception // use m_ssn to generate the exception
getSsn().assertFlushed(this); getSsn().assertFlushed(this);
@ -460,21 +492,21 @@ class DataObjectImpl implements DataObject {
ObserverEntry entry = new ObserverEntry(observer); ObserverEntry entry = new ObserverEntry(observer);
if (!m_observers.contains(entry)) { if (!m_observers.contains(entry)) {
if (m_firing != null) { if (m_firing != null) {
throw new IllegalStateException throw new IllegalStateException("Can't add a new observer from within another "
("Can't add a new observer from within another " + + "observer.\n"
"observer.\n" + + "Trying to add: " + observer
"Trying to add: " + observer + "\n" + + "\n" + "Currently firing: "
"Currently firing: " + m_firing + "\n" + + m_firing + "\n"
"Current observers: " + m_observers); + "Current observers: "
+ m_observers);
} }
m_observers.add(entry); m_observers.add(entry);
} }
} }
private ObserverEntry m_firing = null; private ObserverEntry m_firing = null;
void scheduleObserver(DataEvent event) { void scheduleObserver(DataEvent event) {
for (Iterator it = m_observers.iterator(); it.hasNext(); ) { for (Iterator it = m_observers.iterator(); it.hasNext();) {
ObserverEntry entry = (ObserverEntry) it.next(); ObserverEntry entry = (ObserverEntry) it.next();
DataObserver observer = entry.getObserver(); DataObserver observer = entry.getObserver();
if (event instanceof AfterEvent) { if (event instanceof AfterEvent) {
@ -488,7 +520,9 @@ class DataObjectImpl implements DataObject {
ObserverEntry entry = (ObserverEntry) m_observers.get(i); ObserverEntry entry = (ObserverEntry) m_observers.get(i);
final DataObserver observer = entry.getObserver(); final DataObserver observer = entry.getObserver();
if (entry.isFiring(event)) { if (entry.isFiring(event)) {
if (s_log.isDebugEnabled()) { s_log.debug("isFiring: " + event); } if (s_log.isDebugEnabled()) {
s_log.debug("isFiring: " + event);
}
continue; continue;
} }
@ -510,7 +544,9 @@ class DataObjectImpl implements DataObject {
// after events never delay firing // after events never delay firing
if (event instanceof BeforeEvent) { if (event instanceof BeforeEvent) {
DataEvent waiting = entry.clearFiring(event); DataEvent waiting = entry.clearFiring(event);
if (waiting != null) { fireObserver(waiting); } if (waiting != null) {
fireObserver(waiting);
}
} }
entry.setFiring(event); entry.setFiring(event);
@ -518,7 +554,9 @@ class DataObjectImpl implements DataObject {
event.invoke(observer); event.invoke(observer);
DataEvent waiting = entry.clearFiring(event); DataEvent waiting = entry.clearFiring(event);
if (waiting != null) { fireObserver(waiting); } if (waiting != null) {
fireObserver(waiting);
}
} finally { } finally {
entry.clearFiring(event); entry.clearFiring(event);
} }
@ -549,5 +587,4 @@ class DataObjectImpl implements DataObject {
public String toString() { public String toString() {
return m_oid.toString(); return m_oid.toString();
} }
} }

View File

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
/** /**
* The ObjectType class is a specialized form of CompoundType that supports * The ObjectType class is a specialized form of CompoundType that supports
* inheritence. It also adds the notion of identity by allowing properties to * inheritence. It also adds the notion of identity by allowing properties to
@ -36,59 +35,49 @@ import java.util.Iterator;
*/ */
public class ObjectType extends CompoundType { public class ObjectType extends CompoundType {
static ObjectType static ObjectType wrap(com.redhat.persistence.metadata.ObjectType type) {
wrap(com.redhat.persistence.metadata.ObjectType type) { if (type == null) {
if (type == null) { return null;
return null; } else {
} else { return new ObjectType(type);
return new ObjectType(type); }
}
} }
static Collection wrap(Collection types) { static Collection wrap(Collection types) {
ArrayList result = new ArrayList(types.size()); ArrayList result = new ArrayList(types.size());
for (Iterator it = types.iterator(); it.hasNext(); ) { for (Iterator it = types.iterator(); it.hasNext();) {
result.add result.add(wrap(
(wrap((com.redhat.persistence.metadata.ObjectType) (com.redhat.persistence.metadata.ObjectType) it.next()));
it.next())); }
} return result;
return result;
} }
private com.redhat.persistence.metadata.ObjectType m_type; private com.redhat.persistence.metadata.ObjectType m_type;
private private ObjectType(com.redhat.persistence.metadata.ObjectType type) {
ObjectType(com.redhat.persistence.metadata.ObjectType type) { super(type);
super(type);
m_type = type; m_type = type;
} }
/** /**
* Returns the supertype of this ObjectType or null if this is a base * Returns the supertype of this ObjectType or null if this is a base
* type. * type.
* *
* @return The supertype of this ObjectType or null if this is a base. * @return The supertype of this ObjectType or null if this is a base.
**/ **/
public ObjectType getSupertype() { public ObjectType getSupertype() {
return ObjectType.wrap(m_type.getSupertype()); return ObjectType.wrap(m_type.getSupertype());
} }
/** /**
* Returns the base type of this ObjectType (which may simply be the * Returns the base type of this ObjectType (which may simply be the
* current ObjectType). * current ObjectType).
* *
* @return The base type of this ObjectType. * @return The base type of this ObjectType.
**/ **/
public ObjectType getBasetype() { public ObjectType getBasetype() {
return ObjectType.wrap(m_type.getBasetype()); return ObjectType.wrap(m_type.getBasetype());
} }
/** /**
* Returns true if the given Property is one of the key Properties on this * Returns true if the given Property is one of the key Properties on this
* ObjectType. * ObjectType.
@ -97,7 +86,7 @@ public class ObjectType extends CompoundType {
* @return true if is a key property. * @return true if is a key property.
*/ */
public boolean isKeyProperty(Property p) { public boolean isKeyProperty(Property p) {
return m_type.isKeyProperty(p.getName()); return m_type.isKeyProperty(p.getName());
} }
/** /**
@ -108,7 +97,7 @@ public class ObjectType extends CompoundType {
* @return true if is a key property. * @return true if is a key property.
*/ */
public boolean isKeyProperty(String name) { public boolean isKeyProperty(String name) {
return m_type.isKeyProperty(name); return m_type.isKeyProperty(name);
} }
/** /**
@ -119,9 +108,8 @@ public class ObjectType extends CompoundType {
* *
* @see Property * @see Property
**/ **/
public Iterator getKeyProperties() { public Iterator getKeyProperties() {
return Property.wrap(m_type.getKeyProperties()).iterator(); return Property.wrap(m_type.getKeyProperties()).iterator();
} }
/** /**
@ -133,7 +121,6 @@ public class ObjectType extends CompoundType {
* *
* @see Property * @see Property
**/ **/
public Iterator getProperties() { public Iterator getProperties() {
return Property.wrap(m_type.getProperties()).iterator(); return Property.wrap(m_type.getProperties()).iterator();
} }
@ -147,12 +134,10 @@ public class ObjectType extends CompoundType {
* *
* @see Property * @see Property
**/ **/
public Iterator getDeclaredProperties() { public Iterator getDeclaredProperties() {
return Property.wrap(m_type.getDeclaredProperties()).iterator(); return Property.wrap(m_type.getDeclaredProperties()).iterator();
} }
/** /**
* Returns true if this ObjectType contains a Property with the given * Returns true if this ObjectType contains a Property with the given
* name. This includes any Properties inherited from the supertype. * name. This includes any Properties inherited from the supertype.
@ -162,12 +147,10 @@ public class ObjectType extends CompoundType {
* @return True if this ObjectType contains a Property with the given * @return True if this ObjectType contains a Property with the given
* name, false otherwise. * name, false otherwise.
**/ **/
public boolean hasProperty(String name) { public boolean hasProperty(String name) {
return m_type.hasProperty(name); return m_type.hasProperty(name);
} }
/** /**
* Returns true if this ObjectType directly defines a Property with the * Returns true if this ObjectType directly defines a Property with the
* given name. This does <i>not</i> any Properties inherited from the * given name. This does <i>not</i> any Properties inherited from the
@ -178,12 +161,10 @@ public class ObjectType extends CompoundType {
* @return True if this ObjectType contains a directly defined Property * @return True if this ObjectType contains a directly defined Property
* with the given name, false otherwise. * with the given name, false otherwise.
**/ **/
public boolean hasDeclaredProperty(String name) { public boolean hasDeclaredProperty(String name) {
return m_type.hasDeclaredProperty(name); return m_type.hasDeclaredProperty(name);
} }
/** /**
* Returns the Property contained by this ObjectType with the given name * Returns the Property contained by this ObjectType with the given name
* or null if no such property exists. This includes any properties that * or null if no such property exists. This includes any properties that
@ -193,12 +174,10 @@ public class ObjectType extends CompoundType {
* *
* @return An instance of Property or null. * @return An instance of Property or null.
**/ **/
public Property getProperty(String name) { public Property getProperty(String name) {
return Property.wrap(m_type.getProperty(name)); return Property.wrap(m_type.getProperty(name));
} }
/** /**
* Returns the Property directly defined by this ObjectType with the given * Returns the Property directly defined by this ObjectType with the given
* name or null if no such property exists. This does <i>not</i> include * name or null if no such property exists. This does <i>not</i> include
@ -208,18 +187,15 @@ public class ObjectType extends CompoundType {
* *
* @return An instance of Property or null. * @return An instance of Property or null.
**/ **/
public Property getDeclaredProperty(String name) { public Property getDeclaredProperty(String name) {
return Property.wrap(m_type.getDeclaredProperty(name)); return Property.wrap(m_type.getDeclaredProperty(name));
} }
/** /**
* @see #isSubtypeOf(ObjectType) * @see #isSubtypeOf(ObjectType)
**/ **/
public boolean isSubtypeOf(String qualifiedName) { public boolean isSubtypeOf(String qualifiedName) {
return m_type.isSubtypeOf(qualifiedName); return m_type.isSubtypeOf(qualifiedName);
} }
/** /**
@ -233,12 +209,10 @@ public class ObjectType extends CompoundType {
* *
* @return True if this ObjectType is a subtype of <i>type</i>. * @return True if this ObjectType is a subtype of <i>type</i>.
**/ **/
public boolean isSubtypeOf(ObjectType type) { public boolean isSubtypeOf(ObjectType type) {
return m_type.isSubtypeOf(type.m_type); return m_type.isSubtypeOf(type.m_type);
} }
/** /**
* Checks if the <code>ObjectType</code> specified by <code>extendedType</code> * Checks if the <code>ObjectType</code> specified by <code>extendedType</code>
* is a subtype of the <code>ObjectType</code> specified by <code>baseType</code>. * is a subtype of the <code>ObjectType</code> specified by <code>baseType</code>.
@ -255,35 +229,32 @@ public class ObjectType extends CompoundType {
public static void verifySubtype(ObjectType baseType, public static void verifySubtype(ObjectType baseType,
ObjectType extendedType) { ObjectType extendedType) {
if (!extendedType.isSubtypeOf(baseType)) { if (!extendedType.isSubtypeOf(baseType)) {
throw new PersistenceException throw new PersistenceException("The object type '" + extendedType.
("The object type '" + extendedType.getQualifiedName() + getQualifiedName()
"' is not a subtype of the object type '" + + "' is not a subtype of the object type '"
baseType.getQualifiedName() + "'"); + baseType.getQualifiedName() + "'");
} }
} }
public static void verifySubtype(String baseType, public static void verifySubtype(String baseType,
String extendedType) { String extendedType) {
verifySubtype verifySubtype(MetadataRoot.getMetadataRoot().getObjectType(baseType),
(MetadataRoot.getMetadataRoot().getObjectType(baseType), MetadataRoot.getMetadataRoot().getObjectType(extendedType));
MetadataRoot.getMetadataRoot().getObjectType(extendedType));
} }
public static void verifySubtype(String baseType, public static void verifySubtype(String baseType,
ObjectType extendedType) { ObjectType extendedType) {
ObjectType baseObjectType = ObjectType baseObjectType =
MetadataRoot.getMetadataRoot().getObjectType(baseType); MetadataRoot.getMetadataRoot().getObjectType(baseType);
Assert.isTrue(baseObjectType != null, Assert.isTrue(baseObjectType != null,
"Could not find the ObjectType for the " + "Could not find the ObjectType for the "
"base type. The base type was: " + baseType + "."); + "base type. The base type was: " + baseType + ".");
verifySubtype(baseObjectType, extendedType); verifySubtype(baseObjectType, extendedType);
} }
public static void verifySubtype(ObjectType baseType, public static void verifySubtype(ObjectType baseType,
String extendedType) { String extendedType) {
verifySubtype verifySubtype(baseType,
(baseType, MetadataRoot.getMetadataRoot().getObjectType(extendedType));
MetadataRoot.getMetadataRoot().getObjectType(extendedType));
} }
} }

View File

@ -1,15 +1,10 @@
package com.arsdigita.london.util.cmd; package com.arsdigita.london.util.cmd;
import com.arsdigita.cms.installer.xml.XMLContentItemHandler;
import com.arsdigita.cms.installer.xml.XMLContentTypeHandler; import com.arsdigita.cms.installer.xml.XMLContentTypeHandler;
import com.arsdigita.london.util.Transaction; import com.arsdigita.london.util.Transaction;
import com.arsdigita.packaging.Program; import com.arsdigita.packaging.Program;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.TransactionContext;
import com.arsdigita.xml.XML; import com.arsdigita.xml.XML;
import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
/** /**
* *
@ -22,8 +17,6 @@ public class ReloadAuthoringSteps extends Program {
"1.0.0", "1.0.0",
""); "");
} }
@Override @Override
@ -57,7 +50,10 @@ public class ReloadAuthoringSteps extends Program {
XML.parseResource(defToReload, handler); XML.parseResource(defToReload, handler);
} }
}.run(); }.run();
System.out.printf("Reloaded AuthoringSteps from '%s'.", defToReload); System.out.printf("Reloaded AuthoringSteps from '%s'.", defToReload);
}
public static void main(String[] args) {
new ReloadAuthoringSteps().run(args);
} }
} }

View File

@ -1,30 +0,0 @@
model com.arsdigita.cms.contentassets;
import com.arsdigita.kernel.ACSObject;
import com.arsdigita.cms.*;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
association {
GenericOrganizationalUnit[0..n] organizations = join ct_publications.publication_id
to cms_organization_publication_map.publication_id,
join cms_organization_publication_map.organization_id
to cms_organizationalunits.organizationalunit_id;
Publication[0..n] publications = join cms_organizationalunits.organizationalunit_id
to cms_organization_publication_map.organization_id,
join cms_organization_publication_map.publication_id
to ct_publications.publication_id;
}
query getIdsOfPublicationsOfSciOrganization {
BigDecimal publicationId;
do {
select cms_organization_publication_map.publication_id
from cms_organization_publication_map
where cms_organization_publication_map.organization_id = :organization
} map {
publicationId = cms_organization_publication_map.publication_id;
}
}

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
</xrd:context>
</xrd:adapters>

View File

@ -1,17 +0,0 @@
<load>
<requires>
<table name="inits"/>
<table name="acs_objects"/>
<table name="cms_items"/>
<table name="ct_publications"/>
<initalizer class="com.arsdigita.cms.Initializer"/>
<initalizer class="com.arsdigita.cms.contenttypes.PublicationInitializer"/>
</requires>
<provides>
<initializer class="com.arsdigita.cms.contentassets.SciOrganizationPublicationInitializer"/>
</provides>
<scripts>
<schema directory="ccm-sci-assets-organizationpublicationlink"/>
<data class="com.arsdigita.cms.contentassets.SciOrganizationPublicationLoader"/>
</scripts>
</load>

View File

@ -1,163 +0,0 @@
package com.arsdigita.cms.contentassets;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentPage;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitWithPublications;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.SciDepartment;
import com.arsdigita.cms.contenttypes.SciMember;
import com.arsdigita.cms.dispatcher.ContentItemDispatcher;
import com.arsdigita.cms.installer.xml.ContentItemHelper;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.Session;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.persistence.TransactionContext;
import java.math.BigDecimal;
import javax.sound.sampled.TargetDataLine;
/**
*
* @author Jens Pelzetter
*/
public class ConvertRelatedPublicationsLinkToPublicationAssoc {
public static void main(String[] args) {
final com.arsdigita.runtime.Runtime runtime =
new com.arsdigita.runtime.Runtime();
runtime.startup();
final Session session = SessionManager.getSession();
final TransactionContext tc = session.getTransactionContext();
tc.beginTxn();
try {
DataCollection data = session.retrieve(
SciDepartment.BASE_DATA_OBJECT_TYPE);
data.addOrder("title");
SciDepartment department;
while (data.next()) {
department =
(SciDepartment) DomainObjectFactory.newInstance(data.
getDataObject());
if (department.isDraftVersion()) {
System.out.printf("Found department '%s'\n",
department.getTitle());
DataCollection relatedLinks = RelatedLink.getRelatedLinks(
department, "SciDepartmentPublications");
System.out.printf(
"Found %d related links from department '%s' with link list name '%s':\n",
relatedLinks.size(),
department.getTitle(),
"SciDepartmentPublications");
int i = 1;
while (relatedLinks.next()) {
RelatedLink relatedLink =
(RelatedLink) DomainObjectFactory.
newInstance(relatedLinks.getDataObject());
if (relatedLink == null) {
System.out.println(
"Failed to convert related link to domain object...");
continue;
}
ContentItem target = relatedLink.getTargetItem();
Publication publication = (Publication) target;
System.out.printf(
"\tconverting related link to '%s' (%d of %d)\n",
publication.getTitle(),
i,
relatedLinks.size());
GenericOrganizationalUnitWithPublications orga =
new GenericOrganizationalUnitWithPublications(
department.getID());
orga.addPublication(publication);
relatedLink.delete();
i++;
}
}
}
DataCollection persons = session.retrieve(
GenericPerson.BASE_DATA_OBJECT_TYPE);
persons.addOrder("surname");
persons.addOrder("givenname");
GenericPerson person;
while (persons.next()) {
person =
(GenericPerson) DomainObjectFactory.newInstance(persons.
getDataObject());
if (person.isDraftVersion()) {
System.out.printf("Found person '%s'\n",
person.getGivenName(),
person.getSurname());
DataCollection relatedLinks = RelatedLink.getRelatedLinks(
person, "MyPublications");
System.out.printf(
"Found %d related links from person '%s' '%s' with link list name '%s'\n",
relatedLinks.size(),
person.getGivenName(),
person.getSurname(),
"MyPublications");
int i = 1;
while (relatedLinks.next()) {
RelatedLink relatedLink =
(RelatedLink) DomainObjectFactory.
newInstance(relatedLinks.getDataObject());
if (relatedLink == null) {
System.out.println(
"Failed to convert related link to domain object...");
continue;
}
ContentItem target = relatedLink.getTargetItem();
if (target == null) {
System.out.println(
"\t Strange: Target item is null. But thats no problem, since we are only deleting this related link.");
} else {
Publication publication = (Publication) target;
System.out.printf(
"\tDeleting obsolete related link to '%s' (%d of %d)\n",
publication.getTitle(),
i,
relatedLinks.size());
}
relatedLink.delete();
i++;
}
}
}
tc.commitTxn();
} catch (Exception ex) {
System.out.println("Exception ocurred during convert process:");
ex.printStackTrace(System.err);
} finally {
if (tc.inTxn()) {
tc.abortTxn();
}
}
}
}

View File

@ -1,43 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection;
/**
*
* @author Jens Pelzetter
*/
public class PublicationSciOrganizationCollection extends DomainCollection {
public PublicationSciOrganizationCollection(final DataCollection dataCollection) {
super(dataCollection);
m_dataCollection.addOrder("title");
}
public GenericOrganizationalUnit getOrganization() {
return (GenericOrganizationalUnit) DomainObjectFactory.newInstance(m_dataCollection.
getDataObject());
}
}

View File

@ -1,43 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.domain.DomainCollection;
import com.arsdigita.domain.DomainObjectFactory;
import com.arsdigita.persistence.DataCollection;
/**
*
* @author Jens Pelzetter
*/
public class SciOrganizationPublicationCollection extends DomainCollection {
public SciOrganizationPublicationCollection(final DataCollection dataCollection) {
super(dataCollection);
m_dataCollection.addOrder("title");
}
public Publication getPublication() {
return (Publication) DomainObjectFactory.newInstance(m_dataCollection.
getDataObject());
}
}

View File

@ -1,131 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets;
import com.arsdigita.cms.contentassets.ui.PublicationSciOrganizationStep;
import com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationStep;
import com.arsdigita.cms.contenttypes.ContentAssetTraversalHandler;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.SciDepartment;
import com.arsdigita.cms.contenttypes.SciOrganization;
import com.arsdigita.cms.contenttypes.SciProject;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.db.DbHelper;
import com.arsdigita.globalization.GlobalizedMessage;
import com.arsdigita.persistence.pdl.ManifestSource;
import com.arsdigita.persistence.pdl.NameFilter;
import com.arsdigita.runtime.CompoundInitializer;
import com.arsdigita.runtime.DomainInitEvent;
import com.arsdigita.runtime.PDLInitializer;
import com.arsdigita.runtime.RuntimeConfig;
import com.arsdigita.xml.XML;
/**
*
* @author Jens Pelzetter
*/
public class SciOrganizationPublicationInitializer extends CompoundInitializer {
public SciOrganizationPublicationInitializer() {
final String url = RuntimeConfig.getConfig().getJDBCURL();
final int database = DbHelper.getDatabaseFromURL(url);
System.err.println("Creating SciOrganizationPublicationInitializer...");
add(new PDLInitializer(
new ManifestSource(
"ccm-sci-assets-organizationpublicationlink.pdl.mf",
new NameFilter(DbHelper.getDatabaseSuffix(database), "pdl"))));
System.err.println("Constructor of SciOrganizationPublicationInitializer finished...");
}
@Override
public void init(DomainInitEvent event) {
System.out.println("Beginning init of SciOrganizationPublicationInitializer...");
System.out.println("Calling super.init()");
super.init(event);
System.out.println("Creating traversal handler...");
final String traversal = getTraversalXML();
XML.parseResource(traversal,
new ContentAssetTraversalHandler(getProperty()));
System.out.println("Registering authoring step for publications of an organization...");
AuthoringKitWizard.registerAssetStep(
SciOrganization.BASE_DATA_OBJECT_TYPE,
SciOrganizationPublicationStep.class,
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfOrganization",
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfOrganization",
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
99);
System.out.println("Registering authoring step for publications of a department..");
AuthoringKitWizard.registerAssetStep(
SciDepartment.BASE_DATA_OBJECT_TYPE,
SciOrganizationPublicationStep.class,
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfDepartment",
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfDepartment",
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
99);
System.out.println("Registering authoring step for publications of a project...");
AuthoringKitWizard.registerAssetStep(
SciProject.BASE_DATA_OBJECT_TYPE,
SciOrganizationPublicationStep.class,
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfProject",
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
new GlobalizedMessage("sciorganizationpublication.ui.publicationsOfProject",
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
1);
System.out.println("Registering authoring step of organization of a publication...");
AuthoringKitWizard.registerAssetStep(
Publication.BASE_DATA_OBJECT_TYPE,
PublicationSciOrganizationStep.class,
new GlobalizedMessage("sciorganizationpublication.ui.organizationsOfPublication",
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
new GlobalizedMessage("ssciorganizationpublication.ui.organizationsOfPublication",
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"),
1);
System.err.println("Finished init of SciOrganizationPublicationInitializer.");
}
/**
*
* @return
*/
public String getTraversalXML() {
return "/WEB-INF/traversal-adapters/com/arsdigita/"
+ "cms/contentassets/SciOrganizationPublication.xml";
}
/**
*
* @return
*/
public String getProperty() {
return "publications";
}
}

View File

@ -1,35 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets;
import com.arsdigita.loader.PackageLoader;
import com.arsdigita.runtime.ScriptContext;
/**
*
* @author Jens Pelzetter
*/
public class SciOrganizationPublicationLoader extends PackageLoader {
public void run(final ScriptContext cts) {
//Nothing to do.
}
}

View File

@ -1,88 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.PublicationWithOrganization;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import java.math.BigDecimal;
/**
*
* @author Jens Pelzetter
*/
public class PublicationSciOrganizationAddForm
extends BasicItemForm
implements FormProcessListener,
FormInitListener {
private ItemSearchWidget itemSearch;
private final String ITEM_SEARCH = "organizations";
public PublicationSciOrganizationAddForm(ItemSelectionModel itemModel) {
super("OrganizationsAddForm", itemModel);
}
@Override
public void addWidgets() {
add(new Label((String) SciOrganizationPublicationGlobalizationUtil.
globalize("sciorganization.ui.selectOrganization").localize()));
itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType(GenericOrganizationalUnit.class.
getName()));
add(itemSearch);
}
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
PageState state = fse.getPageState();
setVisible(state, true);
}
@Override
public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
Publication pub = (Publication) getItemSelectionModel().
getSelectedObject(state);
PublicationWithOrganization publication =
new PublicationWithOrganization(
pub.getOID());
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
publication.addOrganization((GenericOrganizationalUnit) data.get(
ITEM_SEARCH));
}
init(fse);
}
}

View File

@ -1,61 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
import com.arsdigita.cms.contenttypes.SciOrganization;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
/**
*
* @author Jens Pelzetter
*/
public class PublicationSciOrganizationStep extends SimpleEditStep {
private String ADD_ORGANIZATION_SHEET_NAME = "addOrganization";
public PublicationSciOrganizationStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
this(itemModel, parent, null);
}
public PublicationSciOrganizationStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent,
String prefix) {
super(itemModel, parent, prefix);
BasicItemForm addOrganizationSheet =
new PublicationSciOrganizationAddForm(itemModel);
add(ADD_ORGANIZATION_SHEET_NAME,
(String) SciOrganizationPublicationGlobalizationUtil.globalize(
"sciorganizationpublication.ui.addOrganization").localize(),
new WorkflowLockedComponentAccess(addOrganizationSheet, itemModel),
addOrganizationSheet.getSaveCancelSection().getCancelButton());
PublicationSciOrganizationTable organizationTable =
new PublicationSciOrganizationTable(
itemModel);
setDisplayComponent(organizationTable);
}
}

View File

@ -1,267 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Link;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.event.TableActionEvent;
import com.arsdigita.bebop.event.TableActionListener;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.PublicationSciOrganizationCollection;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.PublicationWithOrganization;
import com.arsdigita.cms.dispatcher.ItemResolver;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.dispatcher.ObjectNotFoundException;
import com.arsdigita.util.Assert;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
/**
*
* @author Jens Pelzetter
*/
public class PublicationSciOrganizationTable
extends Table
implements TableActionListener {
private final String TABLE_COL_EDIT = "table_col_edit";
private final String TABLE_COL_DEL = "table_col_del";
private ItemSelectionModel itemModel;
public PublicationSciOrganizationTable(ItemSelectionModel itemModel) {
super();
this.itemModel = itemModel;
setEmptyView(new Label(SciOrganizationPublicationGlobalizationUtil.
globalize("sciorganizationpublication.ui.organizations.none")));
TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn(
0,
SciOrganizationPublicationGlobalizationUtil.globalize(
"sciorganizationpublication.ui.organization").localize(),
TABLE_COL_EDIT));
columnModel.add(new TableColumn(
1,
SciOrganizationPublicationGlobalizationUtil.globalize(
"sciorganizationpublication.ui.organization.remove").
localize(), TABLE_COL_DEL));
setModelBuilder(new PublicationSciOrganizationTableModelBuilder(
itemModel));
columnModel.get(0).setCellRenderer(new EditCellRenderer());
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
}
private class PublicationSciOrganizationTableModelBuilder
extends LockableImpl
implements TableModelBuilder {
private ItemSelectionModel itemModel;
public PublicationSciOrganizationTableModelBuilder(
ItemSelectionModel itemModel) {
this.itemModel = itemModel;
}
public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state);
Publication publication = (Publication) itemModel.getSelectedObject(
state);
return new PublicationSciOrganizationTableModel(table,
state,
publication);
}
}
private class PublicationSciOrganizationTableModel
implements TableModel {
private Table table;
private PublicationSciOrganizationCollection organizations;
private GenericOrganizationalUnit orga;
public PublicationSciOrganizationTableModel(Table table,
PageState state,
Publication pub) {
PublicationWithOrganization publication;
this.table = table;
publication = new PublicationWithOrganization(pub.getOID());
organizations = publication.getOrganizations();
}
public int getColumnCount() {
return table.getColumnModel().size();
}
public boolean nextRow() {
boolean ret;
if ((organizations != null) && organizations.next()) {
orga = organizations.getOrganization();
ret = true;
} else {
ret = false;
}
return ret;
}
public Object getElementAt(int columnIndex) {
switch (columnIndex) {
case 0:
return orga.getTitle();
case 1:
return SciOrganizationPublicationGlobalizationUtil.globalize(
"sciorganizationpublication.ui.organization.remove").
localize();
default:
return null;
}
}
public Object getKeyAt(int columnIndex) {
return orga.getID();
}
}
private class EditCellRenderer
extends LockableImpl
implements TableCellRenderer {
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int column) {
com.arsdigita.cms.SecurityManager securityManager = Utilities.
getSecurityManager(state);
Publication publication = (Publication) itemModel.getSelectedObject(
state);
boolean canEdit = securityManager.canAccess(
state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
publication);
if (canEdit) {
GenericOrganizationalUnit orga;
try {
orga = new GenericOrganizationalUnit((BigDecimal) key);
} catch (ObjectNotFoundException ex) {
return new Label(value.toString());
}
ContentSection section = CMS.getContext().getContentSection();
ItemResolver resolver = section.getItemResolver();
Link link =
new Link(value.toString(),
resolver.generateItemURL(state,
orga,
section,
orga.getVersion()));
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
private class DeleteCellRenderer
extends LockableImpl
implements TableCellRenderer {
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int column) {
com.arsdigita.cms.SecurityManager securityManager = Utilities.
getSecurityManager(state);
Publication publication = (Publication) itemModel.getSelectedObject(
state);
boolean canEdit = securityManager.canAccess(
state.getRequest(),
com.arsdigita.cms.SecurityManager.DELETE_ITEM,
publication);
if (canEdit) {
ControlLink link = new ControlLink(value.toString());
link.setConfirmation((String) SciOrganizationPublicationGlobalizationUtil.
globalize(
"sciorganizationpublication.ui.organization.confirm.remove").
localize());
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
public void cellSelected(TableActionEvent event) {
PageState state = event.getPageState();
GenericOrganizationalUnit orga = new GenericOrganizationalUnit(new BigDecimal(event.getRowKey().toString()));
Publication pub = (Publication) itemModel.getSelectedObject(
state);
PublicationWithOrganization publication = new PublicationWithOrganization(
pub.getOID());
PublicationSciOrganizationCollection organizations = publication.getOrganizations();
TableColumn column = getColumnModel().get(event.getColumn().intValue());
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
} else if(column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
Assert.exists(orga, GenericOrganizationalUnit.class);
publication.removeOrganization(orga);
}
}
public void headSelected(TableActionEvent event) {
//Nothing to do.
}
}

View File

@ -1,86 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.bebop.FormData;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormProcessListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitWithPublications;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.ui.ItemSearchWidget;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
/**
*
* @author Jens Pelzetter
*/
public class SciOrganizationPublicationAddForm
extends BasicItemForm
implements FormProcessListener,
FormInitListener {
private ItemSearchWidget itemSearch;
private final String ITEM_SEARCH = "publications";
public SciOrganizationPublicationAddForm(ItemSelectionModel itemModel) {
super("PublicationsAddForm", itemModel);
}
@Override
public void addWidgets() {
add(new Label((String) SciOrganizationPublicationGlobalizationUtil.
globalize("sciorganization.ui.selectPublication").localize()));
itemSearch = new ItemSearchWidget(ITEM_SEARCH, ContentType.
findByAssociatedObjectType(Publication.class.getName()));
add(itemSearch);
}
@Override
public void init(FormSectionEvent fse) throws FormProcessException {
PageState state = fse.getPageState();
setVisible(state, true);
}
@Override
public void process(FormSectionEvent fse) throws FormProcessException {
FormData data = fse.getFormData();
PageState state = fse.getPageState();
GenericOrganizationalUnit orga =
(GenericOrganizationalUnit) getItemSelectionModel().
getSelectedObject(state);
GenericOrganizationalUnitWithPublications organization;
organization = new GenericOrganizationalUnitWithPublications(
orga.getOID());
if (this.getSaveCancelSection().getSaveButton().isSelected(state)) {
organization.addPublication((Publication) data.get(ITEM_SEARCH));
}
init(fse);
}
}

View File

@ -1,5 +0,0 @@
sciorganizationpublication.ui.publicationsOfOrganization=Publications of the organization
sciorganizationpublication.ui.publicationsOfDepartment=Publications of the department
sciorganizationpublication.ui.publicationsOfProject=Publications of the project
sciorganizationpublication.ui.organizationsOfPublication=Organizations

View File

@ -1,5 +0,0 @@
sciorganizationpublication.ui.publicationsOfOrganization=Publikationen der Organisation
sciorganizationpublication.ui.publicationsOfDepartment=Publikationen der Abteilung
sciorganizationpublication.ui.publicationsOfProject=Publikationen des Projektes
sciorganizationpublication.ui.organizationsOfPublication=Beteiligte Organizationen

View File

@ -1,60 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
import com.arsdigita.cms.ui.authoring.BasicItemForm;
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
/**
*
* @author Jens Pelzetter
*/
public class SciOrganizationPublicationStep extends SimpleEditStep {
private String ADD_PUBLICATION_SHEET_NAME = "addPublication";
public SciOrganizationPublicationStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
this(itemModel, parent, null);
}
public SciOrganizationPublicationStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent,
String prefix) {
super(itemModel, parent, prefix);
BasicItemForm addPublicationSheet =
new SciOrganizationPublicationAddForm(itemModel);
add(ADD_PUBLICATION_SHEET_NAME,
(String) SciOrganizationPublicationGlobalizationUtil.globalize(
"sciorganizationpublication.ui.addPublication").localize(),
new WorkflowLockedComponentAccess(addPublicationSheet, itemModel),
addPublicationSheet.getSaveCancelSection().getCancelButton());
SciOrganizationPublicationTable publicationTable =
new SciOrganizationPublicationTable(
itemModel);
setDisplayComponent(publicationTable);
}
}

View File

@ -1,278 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.bebop.Component;
import com.arsdigita.bebop.ControlLink;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Link;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.Table;
import com.arsdigita.bebop.event.TableActionEvent;
import com.arsdigita.bebop.event.TableActionListener;
import com.arsdigita.bebop.table.TableCellRenderer;
import com.arsdigita.bebop.table.TableColumn;
import com.arsdigita.bebop.table.TableColumnModel;
import com.arsdigita.bebop.table.TableModel;
import com.arsdigita.bebop.table.TableModelBuilder;
import com.arsdigita.cms.CMS;
import com.arsdigita.cms.ContentSection;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnit;
import com.arsdigita.cms.contenttypes.GenericOrganizationalUnitWithPublications;
import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.dispatcher.ItemResolver;
import com.arsdigita.cms.dispatcher.Utilities;
import com.arsdigita.dispatcher.ObjectNotFoundException;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.util.Assert;
import com.arsdigita.util.LockableImpl;
import java.math.BigDecimal;
/**
*
* @author Jens Pelzetter
*/
public class SciOrganizationPublicationTable
extends Table
implements TableActionListener {
private final String TABLE_COL_EDIT = "table_col_edit";
private final String TABLE_COL_DEL = "table_col_del";
private ItemSelectionModel itemModel;
public SciOrganizationPublicationTable(ItemSelectionModel itemModel) {
super();
this.itemModel = itemModel;
setEmptyView(new Label(SciOrganizationPublicationGlobalizationUtil.
globalize("sciorganizationpublication.ui.publications.none")));
TableColumnModel columnModel = getColumnModel();
columnModel.add(new TableColumn(
0,
SciOrganizationPublicationGlobalizationUtil.globalize(
"sciorganizationpublication.ui.publication").localize(),
TABLE_COL_EDIT));
columnModel.add(new TableColumn(
1,
SciOrganizationPublicationGlobalizationUtil.globalize(
"sciorganizationpublication.ui.publication.remove").localize(),
TABLE_COL_DEL));
setModelBuilder(
new SciOrganizationPublicationTableModelBuilder(itemModel));
columnModel.get(0).setCellRenderer(new EditCellRenderer());
columnModel.get(1).setCellRenderer(new DeleteCellRenderer());
addTableActionListener(this);
}
private class SciOrganizationPublicationTableModelBuilder
extends LockableImpl
implements TableModelBuilder {
private ItemSelectionModel itemModel;
public SciOrganizationPublicationTableModelBuilder(
ItemSelectionModel itemModel) {
this.itemModel = itemModel;
}
@Override
public TableModel makeModel(Table table, PageState state) {
table.getRowSelectionModel().clearSelection(state);
GenericOrganizationalUnit orga =
(GenericOrganizationalUnit) itemModel.
getSelectedObject(state);
return new SciOrganizationPublicationTableModel(table, state, orga);
}
}
private class SciOrganizationPublicationTableModel
implements TableModel {
private Table table;
private SciOrganizationPublicationCollection publications;
private Publication publication;
public SciOrganizationPublicationTableModel(Table table,
PageState state,
GenericOrganizationalUnit orga) {
GenericOrganizationalUnitWithPublications organization;
this.table = table;
organization = new GenericOrganizationalUnitWithPublications(orga.
getOID());
publications = organization.getPublications();
}
public int getColumnCount() {
return table.getColumnModel().size();
}
public boolean nextRow() {
boolean ret;
if ((publications != null) && publications.next()) {
publication = publications.getPublication();
ret = true;
} else {
ret = false;
}
return ret;
}
public Object getElementAt(int columnIndex) {
switch (columnIndex) {
case 0:
return publication.getTitle();
case 1:
return SciOrganizationPublicationGlobalizationUtil.globalize(
"sciorganizationpublication.ui.publication.remove").
localize();
default:
return null;
}
}
public Object getKeyAt(int columnIndex) {
return publication.getID();
}
}
private class EditCellRenderer
extends LockableImpl
implements TableCellRenderer {
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int column) {
com.arsdigita.cms.SecurityManager securityManager = Utilities.
getSecurityManager(state);
GenericOrganizationalUnit orga =
(GenericOrganizationalUnit) itemModel.
getSelectedObject(state);
boolean canEdit = securityManager.canAccess(
state.getRequest(),
com.arsdigita.cms.SecurityManager.EDIT_ITEM,
orga);
if (canEdit) {
Publication publication;
try {
publication = new Publication((BigDecimal) key);
} catch (ObjectNotFoundException ex) {
return new Label(value.toString());
}
ContentSection section = CMS.getContext().getContentSection();
ItemResolver resolver = section.getItemResolver();
Link link = new Link(value.toString(),
resolver.generateItemURL(state,
publication,
section,
publication.
getVersion()));
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
private class DeleteCellRenderer
extends LockableImpl
implements TableCellRenderer {
public Component getComponent(Table table,
PageState state,
Object value,
boolean isSelected,
Object key,
int row,
int column) {
com.arsdigita.cms.SecurityManager securityManager = Utilities.
getSecurityManager(state);
GenericOrganizationalUnit orga =
(GenericOrganizationalUnit) itemModel.
getSelectedObject(state);
boolean canEdit = securityManager.canAccess(
state.getRequest(),
com.arsdigita.cms.SecurityManager.DELETE_ITEM,
orga);
if (canEdit) {
ControlLink link = new ControlLink(value.toString());
link.setConfirmation((String) SciOrganizationPublicationGlobalizationUtil.
globalize(
"sciorganizationpublication.ui.publication.confirm.remove").
localize());
return link;
} else {
Label label = new Label(value.toString());
return label;
}
}
}
@Override
public void cellSelected(TableActionEvent event) {
PageState state = event.getPageState();
Publication publication =
new Publication(new BigDecimal(event.getRowKey().toString()));
GenericOrganizationalUnit orga = (GenericOrganizationalUnit) itemModel.
getSelectedObject(state);
GenericOrganizationalUnitWithPublications organization;
organization =
new GenericOrganizationalUnitWithPublications(orga.getOID());
SciOrganizationPublicationCollection publications =
organization.getPublications();
TableColumn column = getColumnModel().get(event.getColumn().intValue());
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
//Nothing to do here
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
Assert.exists(publication, Publication.class);
organization.removePublication(publication);
}
}
@Override
public void headSelected(TableActionEvent event) {
//Nothing to do.
}
}

View File

@ -1,78 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.util.Assert;
import java.math.BigDecimal;
/**
*
* @author Jens Pelzetter
*/
public class GenericOrganizationalUnitWithPublications extends GenericOrganizationalUnit {
public static final String PUBLICATIONS = "publications";
//public static final String BASE_DATA_OBJECT_TYPE =
// "com.arsdigita.cms.contenttypes.GenericOrganizationalUnit";
private GenericOrganizationalUnitWithPublications() {
this(BASE_DATA_OBJECT_TYPE);
}
public GenericOrganizationalUnitWithPublications(final BigDecimal id)
throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
public GenericOrganizationalUnitWithPublications(final OID oid)
throws DataObjectNotFoundException {
super(oid);
}
public GenericOrganizationalUnitWithPublications(final DataObject dobj) {
super(dobj);
}
private GenericOrganizationalUnitWithPublications(final String type) {
super(type);
}
public SciOrganizationPublicationCollection getPublications() {
return new SciOrganizationPublicationCollection((DataCollection) get(
PUBLICATIONS));
}
public void addPublication(Publication publication) {
Assert.exists(publication, Publication.class);
add(PUBLICATIONS, publication);
}
public void removePublication(Publication publication) {
Assert.exists(publication, Publication.class);
remove(PUBLICATIONS, publication);
}
}

View File

@ -1,75 +0,0 @@
/*
* Copyright (c) 2011 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.contentassets.PublicationSciOrganizationCollection;
import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.persistence.DataCollection;
import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID;
import com.arsdigita.util.Assert;
import java.math.BigDecimal;
/**
*
* @author Jens Pelzetter
*/
public class PublicationWithOrganization extends Publication {
public static final String ORGANIZATIONS = "organizations";
private PublicationWithOrganization() {
this(BASE_DATA_OBJECT_TYPE);
}
public PublicationWithOrganization(BigDecimal id)
throws DataObjectNotFoundException {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
public PublicationWithOrganization(OID oid)
throws DataObjectNotFoundException {
super(oid);
}
public PublicationWithOrganization(DataObject dobj) {
super(dobj);
}
private PublicationWithOrganization(String type) {
super(type);
}
public PublicationSciOrganizationCollection getOrganizations() {
return new PublicationSciOrganizationCollection((DataCollection) get(ORGANIZATIONS));
}
public void addOrganization(GenericOrganizationalUnit orga) {
Assert.exists(orga, GenericOrganizationalUnit.class);
add(ORGANIZATIONS, orga);
}
public void removeOrganization(GenericOrganizationalUnit orga) {
Assert.exists(orga, GenericOrganizationalUnit.class);
remove(ORGANIZATIONS, orga);
}
}

View File

@ -1,17 +0,0 @@
package com.arsdigita.cms.contenttypes;
import java.util.Comparator;
/**
*
* @author Jens Pelzetter
*/
public class SciPublicationComparator implements Comparator<Publication> {
public int compare(Publication publication1, Publication publication2) {
return publication1.getTitle().compareTo(publication2.getTitle());
}
}

View File

@ -20,7 +20,7 @@
</xrd:context> </xrd:context>
<xrd:context name="sciProjectList"> <xrd:context name="sciProjectList">
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.SciProject" extends="com.arsdigita.cms.ContentPage"> <xrd:adapter objectType="com.arsdigita.cms.contenttypes.SciProject" extends="com.arsdigita.cms.ContentPage">-->
<!--<xrd:attributes rule="exclude"> <!--<xrd:attributes rule="exclude">
<xrd:property name="/object/projectDescription"/> <xrd:property name="/object/projectDescription"/>
</xrd:attributes>--> </xrd:attributes>-->

View File

@ -55,7 +55,7 @@ public class SciDepartmentLoader extends AbstractContentTypeLoader {
return TYPES; return TYPES;
} }
@Override @Override
protected void prepareSection(final ContentSection section, protected void prepareSection(final ContentSection section,
final ContentType type, final ContentType type,
final LifecycleDefinition lifecycle, final LifecycleDefinition lifecycle,

View File

@ -1,43 +0,0 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.SciDepartmentPublicationLink;
import com.arsdigita.cms.contentassets.ui.RelatedLinkPropertyForm;
import com.arsdigita.cms.contenttypes.Link;
import com.arsdigita.util.Assert;
/**
*
* @author Jens Pelzetter
*/
public class SciDepartmentPublicationLinkPropertyForm extends RelatedLinkPropertyForm {
public SciDepartmentPublicationLinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel linkModel,
String linkListName) {
this(itemModel, linkModel, linkListName, null);
}
public SciDepartmentPublicationLinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel linkModel,
String linkListName,
ContentType contentType) {
super(itemModel, linkModel, linkListName, contentType);
}
@Override
protected Link createLink(PageState state) {
ContentItem item = getContentItem(state);
Assert.exists(item, ContentItem.class);
SciDepartmentPublicationLink link = new SciDepartmentPublicationLink();
link.setLinkOwner(item);
return link;
}
}

View File

@ -1,54 +0,0 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormSection;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.ui.RelatedLinkPropertiesStep;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
/**
*
* @author Jens Pelzetter
*/
public class SciDepartmentPublicationsStep extends RelatedLinkPropertiesStep {
public SciDepartmentPublicationsStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
super(itemModel, parent);
}
@Override
protected void setLinkSelectionModel() {
super.setLinkSelectionModel();
linkListName = "SciDepartmentPublications";
contentType = ContentType.findByAssociatedObjectType(
"com.arsdigita.cms.contenttypes.Publication");
}
protected FormSection getEditSheet() {
return new SciDepartmentPublicationLinkPropertyForm(
getItemSelectionModel(),
getLinkSelectionModel(),
linkListName,
contentType);
}
}

View File

@ -1,41 +0,0 @@
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentItem;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.SciProjectPublicationLink;
import com.arsdigita.cms.contentassets.ui.RelatedLinkPropertyForm;
import com.arsdigita.cms.contenttypes.Link;
import com.arsdigita.util.Assert;
/**
*
* @author Jens Pelzetter
*/
public class SciProjectPublicationLinkPropertyForm extends RelatedLinkPropertyForm {
public SciProjectPublicationLinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel linkModel,
String linkListName) {
this(itemModel, linkModel, linkListName, null);
}
public SciProjectPublicationLinkPropertyForm(ItemSelectionModel itemModel,
LinkSelectionModel linkModel,
String linkListName,
ContentType contentType) {
super(itemModel, linkModel, linkListName, contentType);
}
@Override
protected Link createLink(PageState state) {
ContentItem item = getContentItem(state);
Assert.exists(item, ContentItem.class);
SciProjectPublicationLink link = new SciProjectPublicationLink();
link.setLinkOwner(item);
return link;
}
}

View File

@ -1,55 +0,0 @@
/*
* Copyright (c) 2010 Jens Pelzetter,
* for the Center of Social Politics of the University of Bremen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.FormSection;
import com.arsdigita.cms.ContentType;
import com.arsdigita.cms.ItemSelectionModel;
import com.arsdigita.cms.contentassets.ui.RelatedLinkPropertiesStep;
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
/**
*
* @author jensp
*/
public class SciProjectPublicationsStep extends RelatedLinkPropertiesStep {
public SciProjectPublicationsStep(ItemSelectionModel itemModel,
AuthoringKitWizard parent) {
super(itemModel, parent);
}
@Override
protected void setLinkSelectionModel() {
super.setLinkSelectionModel();
linkListName = "SciProjectPublications";
contentType = ContentType.findByAssociatedObjectType(
"com.arsdigita.cms.contenttypes.Publication");
}
@Override
protected FormSection getEditSheet() {
return new SciProjectPublicationLinkPropertyForm(
getItemSelectionModel(),
getLinkSelectionModel(),
linkListName,
contentType);
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project" <ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
name = "ccm-sci-assets-organizationpublicationlink" name = "ccm-sci-types-organizationwithpublications"
prettyName = "CCM Sci Assets OrganizationPublicationLink" prettyName = "CCM Sci Organization with publications"
version="6.6.1" version="6.6.1"
release="1" release="1"
webapp="ROOT"> webapp="ROOT">
@ -21,6 +21,7 @@
<ccm:contact uri="mailto:rhea@redhat.com" type="support"/> <ccm:contact uri="mailto:rhea@redhat.com" type="support"/>
</ccm:contacts> </ccm:contacts>
<ccm:description> <ccm:description>
Links a publication to a SciOrganization, SciDepartment or SciProject. Extended versions of the types SciOrganization, SciDepartment and SciProject,
with an association to publications.
</ccm:description> </ccm:description>
</ccm:application> </ccm:application>

View File

@ -0,0 +1,27 @@
<load>
<requires>
<table name="inits"/>
<table name="acs_objects"/>
<table name="cms_items"/>
<table name="ct_sciorga_organizations"/>
<table name="ct_sciorga_departments"/>
<table name="ct_sciorga_projects"/>
<table name="ct_publications"/>
<initalizer class="com.arsdigita.cms.Initializer"/>
<initalizer class="com.arsdigita.cms.contenttypes.PublicationInitializer"/>
<initalizer class="com.arsdigita.cms.contenttypes.SciOrganizationInitializer"/>
<initalizer class="com.arsdigita.cms.contenttypes.SciDepartmentInitializer"/>
<initalizer class="com.arsdigita.cms.contenttypes.SciProjectInitializer"/>
</requires>
<provides>
<initializer class="com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsInitializer"/>
<initializer class="com.arsdigita.cms.contenttypes.SciDepartmentWithPublicationsInitializer"/>
<initializer class="com.arsdigita.cms.contenttypes.SciProjectWithPublicationsInitializer"/>
</provides>
<scripts>
<schema directory="ccm-sci-types-organizationwithpublications"/>
<data class="com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsLoader"/>
<data class="com.arsdigita.cms.contenttypes.SciDepartmentWithPublicationsLoader"/>
<data class="com.arsdigita.cms.contenttypes.SciProjectWithPublicationsLoader"/>
</scripts>
</load>

View File

@ -19,11 +19,12 @@
*/ */
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection; 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.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
@ -31,36 +32,38 @@ import java.math.BigDecimal;
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class SciDepartmentWithPublications extends SciDepartment { public class SciDepartmentWithPublications extends SciDepartment {
private GenericOrganizationalUnitWithPublications departmentWithPublications; public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.SciDepartmentWithPublications";
private SciDepartmentWithPublications() { public static final String PUBLICATIONS = "publications";
public SciDepartmentWithPublications() {
this(BASE_DATA_OBJECT_TYPE);
} }
private SciDepartmentWithPublications(final BigDecimal id) { public SciDepartmentWithPublications(final BigDecimal id) {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
} }
private SciDepartmentWithPublications(final OID oid) { public SciDepartmentWithPublications(final OID oid) {
super(oid);
} }
private SciDepartmentWithPublications(final DataObject dobj) { public SciDepartmentWithPublications(final DataObject dobj) {
super(dobj);
} }
private SciDepartmentWithPublications(final String type) { public SciDepartmentWithPublications(final String type) {
super(type);
} }
public SciDepartmentWithPublications(final SciDepartment department) {
super(department.getID());
departmentWithPublications =
new GenericOrganizationalUnitWithPublications(department.getID());
}
public boolean hasPublications(final boolean merge) { public boolean hasPublications(final boolean merge) {
DataQuery query = DataQuery query =
SessionManager.getSession().retrieveQuery( SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciOrganization"); "com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciDepartment");
query.setParameter("organization", getID()); query.setParameter("department", getID());
if (query.size() > 0) { if (query.size() > 0) {
query.close(); query.close();
return true; return true;
@ -71,7 +74,7 @@ public class SciDepartmentWithPublications extends SciDepartment {
SessionManager.getSession().retrieveQuery( SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.contenttypes.getIdsOfSubDepartmentsOfSciDepartment"); "com.arsdigita.cms.contenttypes.getIdsOfSubDepartmentsOfSciDepartment");
departmentsQuery.setParameter("department", getID()); departmentsQuery.setParameter("department", getID());
if (departmentsQuery.size() > 0) { if (departmentsQuery.size() > 0) {
BigDecimal departmentId; BigDecimal departmentId;
boolean result = false; boolean result = false;
@ -79,12 +82,12 @@ public class SciDepartmentWithPublications extends SciDepartment {
departmentId = (BigDecimal) departmentsQuery.get( departmentId = (BigDecimal) departmentsQuery.get(
"departmentId"); "departmentId");
result = hasPublications(departmentId, merge); result = hasPublications(departmentId, merge);
if (result) { if (result) {
break; break;
} }
} }
departmentsQuery.close(); departmentsQuery.close();
return result; return result;
} else { } else {
@ -97,14 +100,14 @@ public class SciDepartmentWithPublications extends SciDepartment {
} }
} }
} }
private boolean hasPublications(final BigDecimal departmentId, private boolean hasPublications(final BigDecimal departmentId,
final boolean merge) { final boolean merge) {
DataQuery query = DataQuery query =
SessionManager.getSession().retrieveQuery( SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciDepartment"); "com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciDepartment");
query.setParameter("departmentId", departmentId); query.setParameter("departmentId", departmentId);
if (query.size() > 0) { if (query.size() > 0) {
query.close(); query.close();
return true; return true;
@ -115,7 +118,7 @@ public class SciDepartmentWithPublications extends SciDepartment {
SessionManager.getSession().retrieveQuery( SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.contenttypes.getIdsOfSubDepartmentsOfSciDepartment"); "com.arsdigita.cms.contenttypes.getIdsOfSubDepartmentsOfSciDepartment");
subDepartmentsQuery.setParameter("department", departmentId); subDepartmentsQuery.setParameter("department", departmentId);
if (query.size() > 0) { if (query.size() > 0) {
BigDecimal subDepartmentId; BigDecimal subDepartmentId;
boolean result = false; boolean result = false;
@ -123,14 +126,14 @@ public class SciDepartmentWithPublications extends SciDepartment {
subDepartmentId = (BigDecimal) subDepartmentsQuery.get( subDepartmentId = (BigDecimal) subDepartmentsQuery.get(
"departmentId"); "departmentId");
result = hasPublications(subDepartmentId, merge); result = hasPublications(subDepartmentId, merge);
if (result) { if (result) {
break; break;
} }
} }
subDepartmentsQuery.close(); subDepartmentsQuery.close();
return result; return result;
} else { } else {
subDepartmentsQuery.close(); subDepartmentsQuery.close();
return false; return false;
@ -141,8 +144,23 @@ public class SciDepartmentWithPublications extends SciDepartment {
} }
} }
} }
public SciDepartmentPublicationsCollection getPublications() {
return new SciDepartmentPublicationsCollection((DataCollection) get(
PUBLICATIONS));
}
public SciOrganizationPublicationCollection getPublications() { public void addPublication(final Publication publication) {
return departmentWithPublications.getPublications(); Assert.exists(publication, Publication.class);
DataObject link = add(PUBLICATIONS, publication);
link.set("publicationOrder", Integer.valueOf((int) getPublications().size()));
link.save();
}
public void removePublication(final Publication publication) {
Assert.exists(publication, Publication.class);
remove(PUBLICATIONS, publication);
} }
} }

View File

@ -19,11 +19,12 @@
*/ */
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection; 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.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
@ -32,34 +33,37 @@ import java.math.BigDecimal;
*/ */
public class SciOrganizationWithPublications extends SciOrganization { public class SciOrganizationWithPublications extends SciOrganization {
private GenericOrganizationalUnitWithPublications orgaWithPublications; public static final String BASE_DATA_OBJECT_TYPE =
private static final SciOrganizationWithPublicationsConfig config = new SciOrganizationWithPublicationsConfig(); "com.arsdigita.cms.contenttypes.SciOrganizationWithPublications";
public static final String PUBLICATIONS = "publications";
public static final String PUBLICATION_ORDER = "publicationOrder";
private static final SciOrganizationWithPublicationsConfig config =
new SciOrganizationWithPublicationsConfig();
static { static {
config.load(); config.load();
} }
private SciOrganizationWithPublications() { public SciOrganizationWithPublications() {
this(BASE_DATA_OBJECT_TYPE);
} }
private SciOrganizationWithPublications(final BigDecimal id) { public SciOrganizationWithPublications(final BigDecimal id) {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
} }
private SciOrganizationWithPublications(final OID oid) { public SciOrganizationWithPublications(final OID oid) {
super(oid);
} }
private SciOrganizationWithPublications(final DataObject dobj) { public SciOrganizationWithPublications(final DataObject dobj) {
super(dobj);
} }
private SciOrganizationWithPublications(final String type) { public SciOrganizationWithPublications(final String type) {
super(type);
} }
public SciOrganizationWithPublications(final SciOrganization organization) {
super(organization.getID());
orgaWithPublications = new GenericOrganizationalUnitWithPublications(
organization.getID());
}
public static SciOrganizationWithPublicationsConfig getConfig() { public static SciOrganizationWithPublicationsConfig getConfig() {
return config; return config;
} }
@ -67,7 +71,7 @@ public class SciOrganizationWithPublications extends SciOrganization {
public boolean hasPublications(final boolean merge) { public boolean hasPublications(final boolean merge) {
DataQuery query = DataQuery query =
SessionManager.getSession().retrieveQuery( SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciOrganization"); "com.arsdigita.cms.contenttypes.getIdsOfPublicationsOfSciOrganization");
query.setParameter("organization", getID()); query.setParameter("organization", getID());
if (query.size() > 0) { if (query.size() > 0) {
@ -79,8 +83,8 @@ public class SciOrganizationWithPublications extends SciOrganization {
DataQuery departmentsQuery = DataQuery departmentsQuery =
SessionManager.getSession().retrieveQuery( SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.contenttypes.getIdsOfDepartmentsOfSciOrganization"); "com.arsdigita.cms.contenttypes.getIdsOfDepartmentsOfSciOrganization");
departmentsQuery.setParameter("organization", departmentsQuery.setParameter("organization",
getID()); getID());
if (departmentsQuery.size() > 0) { if (departmentsQuery.size() > 0) {
BigDecimal departmentId; BigDecimal departmentId;
@ -125,22 +129,22 @@ public class SciOrganizationWithPublications extends SciOrganization {
SessionManager.getSession().retrieveQuery( SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.contenttypes.getIdsOfSubDepartmentsOfSciDepartment"); "com.arsdigita.cms.contenttypes.getIdsOfSubDepartmentsOfSciDepartment");
subDepartmentsQuery.setParameter("department", departmentId); subDepartmentsQuery.setParameter("department", departmentId);
if (subDepartmentsQuery.size() > 0) { if (subDepartmentsQuery.size() > 0) {
BigDecimal subDepartmentId; BigDecimal subDepartmentId;
boolean result = false; boolean result = false;
while(subDepartmentsQuery.next()) { while (subDepartmentsQuery.next()) {
subDepartmentId = (BigDecimal) subDepartmentsQuery.get( subDepartmentId = (BigDecimal) subDepartmentsQuery.get(
"departmentId"); "departmentId");
result = hasPublications(subDepartmentId, merge); result = hasPublications(subDepartmentId, merge);
if (result) { if (result) {
break; break;
} }
} }
subDepartmentsQuery.close(); subDepartmentsQuery.close();
return result; return result;
} else { } else {
subDepartmentsQuery.close(); subDepartmentsQuery.close();
return false; return false;
@ -151,8 +155,24 @@ public class SciOrganizationWithPublications extends SciOrganization {
} }
} }
} }
public SciOrganizationPublicationCollection getPublications() { public SciOrganizationPublicationsCollection getPublications() {
return orgaWithPublications.getPublications(); return new SciOrganizationPublicationsCollection((DataCollection) get(
PUBLICATIONS));
}
public void addPublication(final Publication publication) {
Assert.exists(publication, Publication.class);
DataObject link = add(PUBLICATIONS, publication);
link.set(PUBLICATION_ORDER, Integer.valueOf(
(int) getPublications().size()));
link.save();
}
public void removePublication(final Publication publication) {
Assert.exists(publication, Publication.class);
remove(PUBLICATIONS, publication);
} }
} }

View File

@ -19,11 +19,12 @@
*/ */
package com.arsdigita.cms.contenttypes; package com.arsdigita.cms.contenttypes;
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection; 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.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.persistence.SessionManager; import com.arsdigita.persistence.SessionManager;
import com.arsdigita.util.Assert;
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
@ -32,33 +33,34 @@ import java.math.BigDecimal;
*/ */
public class SciProjectWithPublications extends SciProject { public class SciProjectWithPublications extends SciProject {
private GenericOrganizationalUnitWithPublications projectWithPublications; public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.cms.contenttypes.SciProjectWithPublications";
public static final String PUBLICATIONS = "publications";
private SciProjectWithPublications() { public SciProjectWithPublications() {
this(BASE_DATA_OBJECT_TYPE);
} }
private SciProjectWithPublications(final BigDecimal id) { public SciProjectWithPublications(final BigDecimal id) {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
} }
private SciProjectWithPublications(final OID oid) { public SciProjectWithPublications(final OID oid) {
super(oid);
} }
private SciProjectWithPublications(final DataObject dobj) { public SciProjectWithPublications(final DataObject dobj) {
super(dobj);
} }
private SciProjectWithPublications(final String type) { public SciProjectWithPublications(final String type) {
} super(type);
public SciProjectWithPublications(final SciProject project) {
super(project.getID());
projectWithPublications =
new GenericOrganizationalUnitWithPublications(project.getID());
} }
public boolean hasPublications(final boolean merge) { public boolean hasPublications(final boolean merge) {
DataQuery query = DataQuery query =
SessionManager.getSession().retrieveQuery( SessionManager.getSession().retrieveQuery(
"com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciOrganization"); "com.arsdigita.cms.contentassets.getIdsOfPublicationsOfSciProject");
query.setParameter("organization", getID()); query.setParameter("organization", getID());
if (query.size() > 0) { if (query.size() > 0) {
@ -141,8 +143,24 @@ public class SciProjectWithPublications extends SciProject {
} }
} }
} }
public SciOrganizationPublicationCollection getPublications() { public SciProjectPublicationsCollection getPublications() {
return projectWithPublications.getPublications(); return new SciProjectPublicationsCollection((DataCollection) get(
PUBLICATIONS));
}
public void addPublication(final Publication publication) {
Assert.exists(publication, Publication.class);
DataObject link = add(PUBLICATIONS, publication);
link.set("publicationOrder", Integer.valueOf((int) getPublications().
size()));
link.save();
}
public void removePublication(final Publication publication) {
Assert.exists(publication, Publication.class);
remove(PUBLICATIONS, publication);
} }
} }

View File

@ -0,0 +1,43 @@
package com.arsdigita.cms.contenttypes;
import java.util.Comparator;
/**
*
* @author Jens Pelzetter
*/
public class SciPublicationTitleComparator implements Comparator<Publication> {
public int compare(Publication publication1, Publication publication2) {
String title1;
String title2;
if (publication1.getTitle().startsWith("\"")) {
title1 = publication1.getTitle().substring(1,
publication1.getTitle().
length() - 1);
} else if (publication1.getTitle().startsWith("'")) {
title1 = publication1.getTitle().substring(1,
publication1.getTitle().
length() - 1);
} else {
title1 = publication1.getTitle();
}
if (publication2.getTitle().startsWith("\"")) {
title2 = publication2.getTitle().substring(2,
publication2.getTitle().
length() - 1);
} else if (publication2.getTitle().startsWith("'")) {
title2 = publication2.getTitle().substring(2,
publication2.getTitle().
length() - 1);
} else {
title2 = publication2.getTitle();
}
return title1.compareTo(title2);
//return publication1.getTitle().compareTo(publication2.getTitle());
}
}

View File

@ -21,14 +21,14 @@ package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentItemXMLRenderer; import com.arsdigita.cms.ContentItemXMLRenderer;
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.SciDepartment; import com.arsdigita.cms.contenttypes.SciDepartment;
import com.arsdigita.cms.contenttypes.SciDepartmentPublicationsCollection;
import com.arsdigita.cms.contenttypes.SciDepartmentSubDepartmentsCollection; import com.arsdigita.cms.contenttypes.SciDepartmentSubDepartmentsCollection;
import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications; import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications;
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications; import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications;
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsConfig; import com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsConfig;
import com.arsdigita.cms.contenttypes.SciPublicationComparator; import com.arsdigita.cms.contenttypes.SciPublicationTitleComparator;
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator; import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.util.Collections; import java.util.Collections;
@ -41,7 +41,7 @@ import java.util.Set;
* *
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class SciDepartmentsWithPublicationsPanel extends SciDepartmentPanel { public class SciDepartmentWithPublicationsPanel extends SciDepartmentPanel {
public static final String SHOW_PUBLICATIONS = "publications"; public static final String SHOW_PUBLICATIONS = "publications";
private boolean displayPublications = true; private boolean displayPublications = true;
@ -64,10 +64,11 @@ public class SciDepartmentsWithPublicationsPanel extends SciDepartmentPanel {
SciOrganizationWithPublications. SciOrganizationWithPublications.
getConfig(); getConfig();
SciDepartmentWithPublications dep = new SciDepartmentWithPublications( SciDepartmentWithPublications dep =
department); (SciDepartmentWithPublications) department;
if ((dep.hasPublications(config.getOrganizationPublicationsMerge())) if ((dep.hasPublications(
config.getOrganizationPublicationsMerge()))
&& displayPublications) { && displayPublications) {
element.newChildElement("publications"); element.newChildElement("publications");
} }
@ -79,14 +80,21 @@ public class SciDepartmentsWithPublicationsPanel extends SciDepartmentPanel {
while (subDepartments.next()) { while (subDepartments.next()) {
SciDepartment dep; SciDepartment dep;
SciDepartmentWithPublications department; SciDepartmentWithPublications department;
SciOrganizationPublicationCollection departmentPublications; SciDepartmentPublicationsCollection departmentPublications;
dep = subDepartments.getSubDepartment(); dep = subDepartments.getSubDepartment();
department = new SciDepartmentWithPublications(dep); department = (SciDepartmentWithPublications) dep;
departmentPublications = department.getPublications(); departmentPublications = department.getPublications();
Publication publication;
while (departmentPublications.next()) { while (departmentPublications.next()) {
publications.add(departmentPublications.getPublication()); publication = (Publication) departmentPublications.
getPublication().getLiveVersion();
if (publication == null) {
continue;
} else {
publications.add(publication);
}
} }
SciDepartmentSubDepartmentsCollection subSubDepartments = dep. SciDepartmentSubDepartmentsCollection subSubDepartments = dep.
@ -102,18 +110,24 @@ public class SciDepartmentsWithPublicationsPanel extends SciDepartmentPanel {
final Element parent, final Element parent,
final PageState state) { final PageState state) {
final SciDepartmentWithPublications dep = final SciDepartmentWithPublications dep =
new SciDepartmentWithPublications( (SciDepartmentWithPublications) department;
department);
if (SciOrganizationWithPublications.getConfig(). if (SciOrganizationWithPublications.getConfig().
getOrganizationPublicationsMerge()) { getOrganizationPublicationsMerge()) {
List<Publication> publications; List<Publication> publications;
publications = new LinkedList<Publication>(); publications = new LinkedList<Publication>();
SciOrganizationPublicationCollection departmentPublications; SciDepartmentPublicationsCollection departmentPublications;
departmentPublications = dep.getPublications(); departmentPublications = dep.getPublications();
Publication publication;
while (departmentPublications.next()) { while (departmentPublications.next()) {
publications.add(departmentPublications.getPublication()); publication = (Publication) departmentPublications.
getPublication().getLiveVersion();
if (publication == null) {
continue;
} else {
publications.add(publication);
}
} }
mergePublications(department.getSubDepartments(), publications); mergePublications(department.getSubDepartments(), publications);
@ -125,7 +139,7 @@ public class SciDepartmentsWithPublicationsPanel extends SciDepartmentPanel {
publicationsSet); publicationsSet);
Collections.sort(publicationsWithoutDoubles, Collections.sort(publicationsWithoutDoubles,
new SciPublicationComparator()); new SciPublicationTitleComparator());
long pageNumber = getPageNumber(state); long pageNumber = getPageNumber(state);
long pageCount = getPageCount(publicationsWithoutDoubles.size()); long pageCount = getPageCount(publicationsWithoutDoubles.size());
@ -145,11 +159,11 @@ public class SciDepartmentsWithPublicationsPanel extends SciDepartmentPanel {
final ContentItemXMLRenderer renderer = new ContentItemXMLRenderer( final ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(
publicationsElem); publicationsElem);
renderer.setWrapAttributes(true); renderer.setWrapAttributes(true);
for (Publication publication : publicationsToShow) { for (Publication pub : publicationsToShow) {
renderer.walk(publication, SimpleXMLGenerator.class.getName()); renderer.walk(pub, SimpleXMLGenerator.class.getName());
} }
} else { } else {
SciOrganizationPublicationCollection departmentPublications; SciDepartmentPublicationsCollection departmentPublications;
departmentPublications = dep.getPublications(); departmentPublications = dep.getPublications();
List<Publication> publications = new LinkedList<Publication>(); List<Publication> publications = new LinkedList<Publication>();
@ -158,7 +172,7 @@ public class SciDepartmentsWithPublicationsPanel extends SciDepartmentPanel {
publications.add(departmentPublications.getPublication()); publications.add(departmentPublications.getPublication());
} }
Collections.sort(publications, new SciPublicationComparator()); Collections.sort(publications, new SciPublicationTitleComparator());
long pageNumber = getPageNumber(state); long pageNumber = getPageNumber(state);
long pageCount = getPageCount(publications.size()); long pageCount = getPageCount(publications.size());

View File

@ -17,18 +17,19 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* *
*/ */
package com.arsdigita.cms.contentassets.ui; package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.cms.contentassets.ui.*;
import com.arsdigita.globalization.GlobalizedMessage; import com.arsdigita.globalization.GlobalizedMessage;
/** /**
* *
* @author Jens Pelzetter * @author Jens Pelzetter
*/ */
public class SciOrganizationPublicationGlobalizationUtil { public class SciOrganizationWithPublicationsGlobalizationUtil {
public static final String BUNDLE_NAME = public static final String BUNDLE_NAME =
"com.arsdigita.cms.contentassets.ui.SciOrganizationPublicationResources"; "com.arsdigita.cms.contenttypes.ui.SciOrganizationWithPublicationsResources";
public static GlobalizedMessage globalize(String key) { public static GlobalizedMessage globalize(String key) {
return new GlobalizedMessage(key, BUNDLE_NAME); return new GlobalizedMessage(key, BUNDLE_NAME);

View File

@ -21,24 +21,21 @@ package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentItemXMLRenderer; import com.arsdigita.cms.ContentItemXMLRenderer;
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
import com.arsdigita.cms.contenttypes.ArticleInCollectedVolume;
import com.arsdigita.cms.contenttypes.ArticleInJournal;
import com.arsdigita.cms.contenttypes.AuthorshipCollection;
import com.arsdigita.cms.contenttypes.GenericPerson;
import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.PublicationWithPublisher;
import com.arsdigita.cms.contenttypes.Publisher;
import com.arsdigita.cms.contenttypes.SciDepartment; import com.arsdigita.cms.contenttypes.SciDepartment;
import com.arsdigita.cms.contenttypes.SciDepartmentPublicationsCollection;
import com.arsdigita.cms.contenttypes.SciDepartmentSubDepartmentsCollection; import com.arsdigita.cms.contenttypes.SciDepartmentSubDepartmentsCollection;
import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications; import com.arsdigita.cms.contenttypes.SciDepartmentWithPublications;
import com.arsdigita.cms.contenttypes.SciOrganization; import com.arsdigita.cms.contenttypes.SciOrganization;
import com.arsdigita.cms.contenttypes.SciOrganizationDepartmentsCollection; import com.arsdigita.cms.contenttypes.SciOrganizationDepartmentsCollection;
import com.arsdigita.cms.contenttypes.SciOrganizationPublicationsCollection;
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications; import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications;
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsConfig; import com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsConfig;
import com.arsdigita.cms.contenttypes.SciPublicationComparator; import com.arsdigita.cms.contenttypes.SciPublicationTitleComparator;
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator; import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
@ -72,8 +69,7 @@ public class SciOrganizationWithPublicationsPanel extends SciOrganizationPanel {
config = SciOrganizationWithPublications.getConfig(); config = SciOrganizationWithPublications.getConfig();
SciOrganizationWithPublications orga = SciOrganizationWithPublications orga =
new SciOrganizationWithPublications( (SciOrganizationWithPublications) organization;
organization);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
if ((orga.hasPublications(config.getOrganizationPublicationsMerge())) if ((orga.hasPublications(config.getOrganizationPublicationsMerge()))
@ -87,18 +83,30 @@ public class SciOrganizationWithPublicationsPanel extends SciOrganizationPanel {
protected void mergePublications( protected void mergePublications(
final SciOrganizationDepartmentsCollection departments, final SciOrganizationDepartmentsCollection departments,
final List<Publication> publications) { final Collection<Publication> publications) {
while (departments.next()) { while (departments.next()) {
SciDepartment dep; SciDepartment dep;
SciDepartmentWithPublications department; SciDepartmentWithPublications department;
SciOrganizationPublicationCollection departmentPublications; SciDepartmentPublicationsCollection departmentPublications;
dep = departments.getDepartment(); dep = departments.getDepartment();
department = new SciDepartmentWithPublications(dep); department = (SciDepartmentWithPublications) dep;
departmentPublications = department.getPublications(); departmentPublications = department.getPublications();
if (publications instanceof ArrayList) {
((ArrayList<Publication>) publications).ensureCapacity(
publications.size()
+ (int) departmentPublications.size());
}
Publication publication;
while (departmentPublications.next()) { while (departmentPublications.next()) {
publications.add(departmentPublications.getPublication()); publication = (Publication) departmentPublications.getPublication().getLiveVersion();
if (publication == null) {
continue;
} else {
publications.add(publication);
}
} }
SciDepartmentSubDepartmentsCollection subDepartments; SciDepartmentSubDepartmentsCollection subDepartments;
@ -114,33 +122,51 @@ public class SciOrganizationWithPublicationsPanel extends SciOrganizationPanel {
final Element parent, final Element parent,
final PageState state) { final PageState state) {
final SciOrganizationWithPublications orga = final SciOrganizationWithPublications orga =
new SciOrganizationWithPublications( (SciOrganizationWithPublications) organization;
organization);
if (SciOrganizationWithPublications.getConfig(). if (SciOrganizationWithPublications.getConfig().
getOrganizationPublicationsMerge()) { getOrganizationPublicationsMerge()) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
List<Publication> publications; List<Publication> publications;
publications = new LinkedList<Publication>(); SciOrganizationPublicationsCollection orgaPublications;
SciOrganizationPublicationCollection orgaPublications;
orgaPublications = orga.getPublications(); orgaPublications = orga.getPublications();
publications = new ArrayList<Publication>((int) orgaPublications.
size());
Publication publication;
while (orgaPublications.next()) { while (orgaPublications.next()) {
publications.add(orgaPublications.getPublication()); publication = (Publication) orgaPublications.getPublication().getLiveVersion();
if (publication == null) {
continue;
} else {
publications.add(publication);
}
} }
mergePublications(organization.getDepartments(), SciOrganizationDepartmentsCollection departments = organization.
publications); getDepartments();
long mergeStart = System.currentTimeMillis();
mergePublications(departments, publications);
System.err.printf("Merged publications in %d ms\n", System.
currentTimeMillis() - mergeStart);
long sortStart = System.currentTimeMillis();
Set<Publication> publicationsSet; Set<Publication> publicationsSet;
List<Publication> publicationWithoutDoubles; List<Publication> publicationWithoutDoubles;
publicationsSet = new HashSet<Publication>(publications); publicationsSet = new HashSet<Publication>(publications);
publicationWithoutDoubles = new LinkedList<Publication>( //publicationWithoutDoubles = new LinkedList<Publication>(
// publicationsSet);
publicationWithoutDoubles = new ArrayList<Publication>(
publicationsSet); publicationsSet);
Collections.sort(publicationWithoutDoubles,
new SciPublicationComparator());
Collections.sort(publicationWithoutDoubles,
new SciPublicationTitleComparator());
System.out.printf("Sorted publications in %d ms\n", System.
currentTimeMillis() - sortStart);
long paginatorStart = System.currentTimeMillis();
long pageNumber = getPageNumber(state); long pageNumber = getPageNumber(state);
long pageCount = getPageCount(publicationWithoutDoubles.size()); long pageCount = getPageCount(publicationWithoutDoubles.size());
long begin = getPaginatorBegin(pageNumber); long begin = getPaginatorBegin(pageNumber);
@ -151,99 +177,28 @@ public class SciOrganizationWithPublicationsPanel extends SciOrganizationPanel {
createPaginatorElement(parent, pageNumber, pageCount, begin, end, createPaginatorElement(parent, pageNumber, pageCount, begin, end,
count, publicationWithoutDoubles.size()); count, publicationWithoutDoubles.size());
System.out.printf("Created paginator in %d ms", System.
currentTimeMillis() - paginatorStart);
List<Publication> publicationsToShow = publicationWithoutDoubles. List<Publication> publicationsToShow = publicationWithoutDoubles.
subList((int) begin, (int) end); subList((int) begin, (int) end);
System.out.printf( System.out.printf(
"\n\nCreating list of publications to show in %d ms.\n\n", "\n\nCreated list of publications to show in %d ms.\n\n",
System.currentTimeMillis() - start); System.currentTimeMillis() - start);
start = System.currentTimeMillis(); start = System.currentTimeMillis();
//final Element publicationsElem = parent.newChildElement( for (Publication pub : publicationsToShow) {
// "publications");
for (Publication publication : publicationsToShow) {
//Element publicationElem = parent.newChildElement(
// "publications");
/*ContentItemXMLRenderer renderer =
new ContentItemXMLRenderer(publicationElem);
renderer.setWrapAttributes(true);
long walkStart = System.currentTimeMillis();
renderer.walk(publication, SimpleXMLGenerator.class.getName());
System.out.printf("\n\nRenderer walked %d ms\n\n", System.currentTimeMillis() - walkStart);*/
/*Element objectTypeElem = publicationElem.newChildElement("objectType");
objectTypeElem.setText(publication.getObjectType().getQualifiedName());
Element yearElem = publicationElem.newChildElement(
"yearOfPublication");
yearElem.setText(publication.getYearOfPublication().toString());
Element miscElem = publicationElem.newChildElement("misc");
miscElem.setText(publication.getMisc());
AuthorshipCollection authors = publication.getAuthors();
while (authors.next()) {
Element authorsElem = publicationElem.newChildElement(
"authors");
Element linkElem = authorsElem.newChildElement("link");
Element editorElem = linkElem.newChildElement("editor");
if (authors.isEditor()) {
editorElem.setText("true");
} else {
editorElem.setText("false");
}
Element authorOrderElem = linkElem.newChildElement(
"authorOrder");
authorOrderElem.setText(authors.getAuthorshipOrder().
toString());
GenericPerson author = authors.getAuthor();
Element surnameElem = authorsElem.newChildElement("surname");
surnameElem.setText(author.getSurname());
Element givennameElem = authorsElem.newChildElement(
"givenname");
givennameElem.setText(author.getGivenName());
}
Element abstractElem = publicationElem.newChildElement(
"abstract");
abstractElem.setText(publication.getAbstract());
if (publication instanceof PublicationWithPublisher) {
PublicationWithPublisher pwp =
(PublicationWithPublisher) publication;
Publisher publisher = pwp.getPublisher();
Element publisherElem = publicationElem.newChildElement(
"publisher");
Element publisherNameElem = publisherElem.newChildElement(
"publisherName");
publisherNameElem.setText(publisher.getPublisherName());
Element publisherPlaceElem = publisherElem.newChildElement(
"place");
publisherPlaceElem.setText(publisher.getPlace());
}
Element titleElem = publicationElem.newChildElement("title");
titleElem.setText(publication.getTitle());
if (publication instanceof ArticleInJournal) {
}
if (publication instanceof ArticleInCollectedVolume) {
}*/
PublicationXmlHelper xmlHelper = PublicationXmlHelper xmlHelper =
new PublicationXmlHelper(parent, new PublicationXmlHelper(parent,
publication); pub);
xmlHelper.generateXml(); xmlHelper.generateXml();
} }
System.out.printf("\n\nGenerated publications XML in %d ms\n\n", System.out.printf("\n\nGenerated publications XML in %d ms\n\n",
System.currentTimeMillis() - start); System.currentTimeMillis() - start);
} else { } else {
SciOrganizationPublicationCollection orgaPublications; SciOrganizationPublicationsCollection orgaPublications;
orgaPublications = orga.getPublications(); orgaPublications = orga.getPublications();
List<Publication> publications = new LinkedList<Publication>(); List<Publication> publications = new LinkedList<Publication>();
@ -252,7 +207,7 @@ public class SciOrganizationWithPublicationsPanel extends SciOrganizationPanel {
publications.add(orgaPublications.getPublication()); publications.add(orgaPublications.getPublication());
} }
Collections.sort(publications, new SciPublicationComparator()); Collections.sort(publications, new SciPublicationTitleComparator());
long pageNumber = getPageNumber(state); long pageNumber = getPageNumber(state);
long pageCount = getPageCount(publications.size()); long pageCount = getPageCount(publications.size());

View File

@ -0,0 +1,35 @@
sciorganizationpublication.ui.publicationsOfOrganization=Publications of the organization
sciorganizationpublication.ui.publicationsOfDepartment=Publications of the department
sciorganizationpublication.ui.publicationsOfProject=Publications of the project
sciorganizationpublication.ui.organizationsOfPublication=Organizations
sciorganizationpublication.ui.organization=Organization
sciorganizationpublication.ui.organization.remove=Remove orgnization
sciorganizationpublication.ui.addOrganization=Add organization
sciorganizationpublication.ui.publication=Publication
sciorganizationpublication.ui.publication.remove=Remove publication
sciorganizationpublication.ui.addPublication=Add publication
sciorganizationpublication.ui.publications.none=No publications found
sciorganizationpublication.ui.organization.publications.title=Publications
sciorganizationpublication.ui.organization.publications.description=Publications
sciorganizationpublication.ui.department.publications.title=Publications
sciorganizationpublication.ui.department.publications.description=Publications
sciorganizationpublication.ui.project.publications.title=Publications
sciorganizationpublication.ui.project.publications.description=Publications
sciorganizationpublication.ui.publication.projects.title=Lists of publications (Projects)
sciorganizationpublication.ui.publication.projects.description=Lists of publications (Projects)
sciorganizationpublication.ui.publication.organization.title=Lists of publications (Organizations)
sciorganizationpublication.ui.publication.organization.description=Lists of publications (Organizations)
sciorganizationpublication.ui.publication.departments.title=Lists of publications (Departments)
sciorganizationpublication.ui.publication.departments.description=Lists of publications (Departments)
sciorganization.ui.selectPublication=Select publication
sciorganizationpublication.ui.publiction.remove=Remove publication
sciorganizationpublication.ui.organizations.none=This publication is not part of any publication list of a organization
sciorganization.ui.selectOrganization=Select organization
sciorganization.ui.addPublication=Add publication
sciorganizationpublication.ui.departments.none=This publication is not part of any publication list of a department
sciorganizationpublication.ui.addDepartment=Add publication to publication list of a department
sciorganization.ui.selectDepartment=Select department
sciorganizationpublication.ui.projects.none=This publication is not part of any publication list of a project
sciorganizationpublication.ui.project.addPublication=Add publication to publication list of a project
sciorganization.ui.selectProject=Select project

View File

@ -0,0 +1,35 @@
sciorganizationpublication.ui.publicationsOfOrganization=Publikationen der Organisation
sciorganizationpublication.ui.publicationsOfDepartment=Publikationen der Abteilung
sciorganizationpublication.ui.publicationsOfProject=Publikationen des Projektes
sciorganizationpublication.ui.organizationsOfPublication=Beteiligte Organizationen
sciorganizationpublication.ui.organization=Organisation
sciorganizationpublication.ui.organization.remove=Organisation entfernen
sciorganizationpublication.ui.addOrganization=Organisation hinzuf\u00fcgen
sciorganizationpublication.ui.publication=Publikation
sciorganizationpublication.ui.publication.remove=Publikation entfernen
sciorganizationpublication.ui.addPublication=Publikation hinzuf\u00fcgen
sciorganizationpublication.ui.publications.none=Keine Publikationen gefunden
sciorganizationpublication.ui.organization.publications.title=Publikationen
sciorganizationpublication.ui.organization.publications.description=Publikationen
sciorganizationpublication.ui.department.publications.title=Publikationen
sciorganizationpublication.ui.department.publications.description=Publikationen
sciorganizationpublication.ui.project.publications.title=Publikationen
sciorganizationpublication.ui.project.publications.description=Publikationen
sciorganizationpublication.ui.publication.projects.title=Publikationslisten (Projekte)
sciorganizationpublication.ui.publication.projects.description=Publikationslisten (Projekte)
sciorganizationpublication.ui.publication.organization.title=Publikationslisten (Organisationen)
sciorganizationpublication.ui.publication.organization.description=Publikationslisten (Organisationen)
sciorganizationpublication.ui.publication.departments.title=Publikationslisten (Abteilungen)
sciorganizationpublication.ui.publication.departments.description=Publikationslisten (Abteilungen)
sciorganization.ui.selectPublication=Publikation w\u00e4hlen
sciorganizationpublication.ui.publiction.remove=Publikation entfernen
sciorganizationpublication.ui.organizations.none=Diese Publikation ist nicht Teil einer Publikationsliste einer Organisation
sciorganization.ui.selectOrganization=Organisation w\u00e4hlen
sciorganization.ui.addPublication=Publikation hinzuf\u00fcgen
sciorganizationpublication.ui.departments.none=Diese Publikation ist nicht Teil einer Publikationsliste einer Abteilung
sciorganizationpublication.ui.addDepartment=Publikation der Publikationsliste einer Abteilung hinzuf\u00fcgen
sciorganization.ui.selectDepartment=Abteilung w\u00e4hlen
sciorganizationpublication.ui.projects.none=Diese Publikation ist nicht Teil einer Publikationsliste eines Projektes
sciorganizationpublication.ui.project.addPublication=Publikation der Publikationsliste eines Projektes hinzuf\u00fcgen
sciorganization.ui.selectProject=Projekt w\u00e4hlen

View File

@ -21,14 +21,14 @@ package com.arsdigita.cms.contenttypes.ui;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
import com.arsdigita.cms.ContentItemXMLRenderer; import com.arsdigita.cms.ContentItemXMLRenderer;
import com.arsdigita.cms.contentassets.SciOrganizationPublicationCollection;
import com.arsdigita.cms.contenttypes.Publication; import com.arsdigita.cms.contenttypes.Publication;
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications; import com.arsdigita.cms.contenttypes.SciOrganizationWithPublications;
import com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsConfig; import com.arsdigita.cms.contenttypes.SciOrganizationWithPublicationsConfig;
import com.arsdigita.cms.contenttypes.SciProject; import com.arsdigita.cms.contenttypes.SciProject;
import com.arsdigita.cms.contenttypes.SciProjectPublicationsCollection;
import com.arsdigita.cms.contenttypes.SciProjectSubProjectsCollection; import com.arsdigita.cms.contenttypes.SciProjectSubProjectsCollection;
import com.arsdigita.cms.contenttypes.SciProjectWithPublications; import com.arsdigita.cms.contenttypes.SciProjectWithPublications;
import com.arsdigita.cms.contenttypes.SciPublicationComparator; import com.arsdigita.cms.contenttypes.SciPublicationTitleComparator;
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator; import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import java.util.Collections; import java.util.Collections;
@ -65,7 +65,7 @@ public class SciProjectWithPublicationsPanel extends SciProjectPanel {
getConfig(); getConfig();
SciProjectWithPublications proj = SciProjectWithPublications proj =
new SciProjectWithPublications(project); (SciProjectWithPublications) project;
if ((proj.hasPublications(config.getOrganizationPublicationsMerge())) if ((proj.hasPublications(config.getOrganizationPublicationsMerge()))
&& displayPublications) { && displayPublications) {
@ -79,14 +79,21 @@ public class SciProjectWithPublicationsPanel extends SciProjectPanel {
while (subProjects.next()) { while (subProjects.next()) {
SciProject proj; SciProject proj;
SciProjectWithPublications project; SciProjectWithPublications project;
SciOrganizationPublicationCollection projectPublications; SciProjectPublicationsCollection projectPublications;
proj = subProjects.getSubProject(); proj = subProjects.getSubProject();
project = new SciProjectWithPublications(proj); project = (SciProjectWithPublications) proj;
projectPublications = project.getPublications(); projectPublications = project.getPublications();
Publication publication;
while (projectPublications.next()) { while (projectPublications.next()) {
publications.add(projectPublications.getPublication()); publication = (Publication) projectPublications.getPublication().
getLiveVersion();
if (publication == null) {
continue;
} else {
publications.add(publication);
}
} }
SciProjectSubProjectsCollection subSubProjects = SciProjectSubProjectsCollection subSubProjects =
@ -101,17 +108,24 @@ public class SciProjectWithPublicationsPanel extends SciProjectPanel {
protected void generatePublicationsXml(final SciProject project, protected void generatePublicationsXml(final SciProject project,
final Element parent, final Element parent,
final PageState state) { final PageState state) {
final SciProjectWithPublications proj = new SciProjectWithPublications( final SciProjectWithPublications proj =
project); (SciProjectWithPublications) project;
if (SciOrganizationWithPublications.getConfig(). if (SciOrganizationWithPublications.getConfig().
getOrganizationPublicationsMerge()) { getOrganizationPublicationsMerge()) {
List<Publication> publications = new LinkedList<Publication>(); List<Publication> publications = new LinkedList<Publication>();
SciOrganizationPublicationCollection projectPublications = proj. SciProjectPublicationsCollection projectPublications = proj.
getPublications(); getPublications();
Publication publication;
while (projectPublications.next()) { while (projectPublications.next()) {
publications.add(projectPublications.getPublication()); publication = (Publication) projectPublications.getPublication().
getLiveVersion();
if (publication == null) {
continue;
} else {
publications.add(publication);
}
} }
mergePublications(project.getSubProjects(), publications); mergePublications(project.getSubProjects(), publications);
@ -122,7 +136,7 @@ public class SciProjectWithPublicationsPanel extends SciProjectPanel {
publicationsWithoutDoubles = new LinkedList<Publication>( publicationsWithoutDoubles = new LinkedList<Publication>(
publicationsSet); publicationsSet);
Collections.sort(publicationsWithoutDoubles, Collections.sort(publicationsWithoutDoubles,
new SciPublicationComparator()); new SciPublicationTitleComparator());
long pageNumber = getPageNumber(state); long pageNumber = getPageNumber(state);
long pageCount = getPageCount(publicationsWithoutDoubles.size()); long pageCount = getPageCount(publicationsWithoutDoubles.size());
@ -142,11 +156,11 @@ public class SciProjectWithPublicationsPanel extends SciProjectPanel {
final ContentItemXMLRenderer renderer = new ContentItemXMLRenderer( final ContentItemXMLRenderer renderer = new ContentItemXMLRenderer(
publicationsElem); publicationsElem);
renderer.setWrapAttributes(true); renderer.setWrapAttributes(true);
for (Publication publication : publicationsToShow) { for (Publication pub : publicationsToShow) {
renderer.walk(publication, SimpleXMLGenerator.class.getName()); renderer.walk(pub, SimpleXMLGenerator.class.getName());
} }
} else { } else {
SciOrganizationPublicationCollection projectPublications = proj. SciProjectPublicationsCollection projectPublications = proj.
getPublications(); getPublications();
List<Publication> publications = new LinkedList<Publication>(); List<Publication> publications = new LinkedList<Publication>();
@ -155,7 +169,7 @@ public class SciProjectWithPublicationsPanel extends SciProjectPanel {
publications.add(projectPublications.getPublication()); publications.add(projectPublications.getPublication());
} }
Collections.sort(publications, new SciPublicationComparator()); Collections.sort(publications, new SciPublicationTitleComparator());
long pageNumber = getPageNumber(state); long pageNumber = getPageNumber(state);
long pageCount = getPageCount(publications.size()); long pageCount = getPageCount(publications.size());
@ -185,7 +199,7 @@ public class SciProjectWithPublicationsPanel extends SciProjectPanel {
final Element element, final Element element,
final PageState state) { final PageState state) {
String show = getShowParam(state); String show = getShowParam(state);
if (SHOW_PUBLICATIONS.equals(show)) { if (SHOW_PUBLICATIONS.equals(show)) {
generatePublicationsXml(project, element, state); generatePublicationsXml(project, element, state);
} else { } else {