Update of /var/cvs/speeltuin/ernst/vpro-wizards/src/nl/vpro/redactie/handlers
In directory
james.mmbase.org:/tmp/cvs-serv22399/applications/vpro-wizards/src/nl/vpro/redactie/handlers
Modified Files:
PosrelSortHandler.java CreateRelationHandler.java
Log Message:
work in progress
See also:
http://cvs.mmbase.org/viewcvs/speeltuin/ernst/vpro-wizards/src/nl/vpro/redactie/handlers
Index: PosrelSortHandler.java
===================================================================
RCS file:
/var/cvs/speeltuin/ernst/vpro-wizards/src/nl/vpro/redactie/handlers/PosrelSortHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- PosrelSortHandler.java 2 Jun 2008 17:13:04 -0000 1.1
+++ PosrelSortHandler.java 18 Aug 2008 19:13:06 -0000 1.2
@@ -128,7 +128,7 @@
}
/**
- * This method checks if there are no multiple occurences of posrel
values.
+ * This method checks if there are no multiple occurrences of posrel
values.
* if this is the case then the posrels will be renumbered starting at
the lowest value that was found.
* @param targetType
* @param containerType
Index: CreateRelationHandler.java
===================================================================
RCS file:
/var/cvs/speeltuin/ernst/vpro-wizards/src/nl/vpro/redactie/handlers/CreateRelationHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- CreateRelationHandler.java 2 Jun 2008 17:13:04 -0000 1.1
+++ CreateRelationHandler.java 18 Aug 2008 19:13:06 -0000 1.2
@@ -12,14 +12,14 @@
import org.mmbase.bridge.util.Queries;
import org.mmbase.util.logging.Logging;
-
/**
- * creates a new relation from a given source node to a given destination node
with a given role. source and destination can be given as
- * either a specific node number of as a reference to a previously mapped
node. all the values in the fields map will be set on the new
- * node. date or file fields are not supported. Errors caused by setting these
values result in a FieldError instance in the
- * resultContainer.Errors map. <br/> With sortfield you can set a sorting
value on the relation (think: posrel: pos). When the role is
- * posrel this fields defaults to pos. for other relations (specializations of
posrel) you can set the field to use. the field must be of
- * type number. With sortPosition you can determine if the new relation should
be added to the begin of the sorted list or the end.
+ * creates a new relation from a given source node to a given destination node
with a given role. source and destination
+ * can be given as either a specific node number of as a reference to a
previously mapped node. all the values in the
+ * fields map will be set on the new node. date or file fields are not
supported. Errors caused by setting these values
+ * result in a FieldError instance in the resultContainer.Errors map. <br/>
With sortfield you can set a sorting value
+ * on the relation (think: posrel: pos). When the role is posrel this fields
defaults to pos. for other relations
+ * (specializations of posrel) you can set the field to use. the field must be
of type number. With sortPosition you can
+ * determine if the new relation should be added to the begin of the sorted
list or the end.
*
* @author ebunders
*
@@ -27,7 +27,8 @@
public class CreateRelationHandler extends Handler<CreateRelationAction> {
private static org.mmbase.util.logging.Logger log =
Logging.getLoggerInstance(CreateRelationHandler.class);
- public CreateRelationHandler(Transaction transactionalCloud,
ResultContainer resultContainer, Map<String, Node> idMap) {
+ public CreateRelationHandler(Transaction transactionalCloud,
ResultContainer resultContainer,
+ Map<String, Node> idMap) {
super(transactionalCloud, resultContainer, idMap);
}
@@ -41,15 +42,16 @@
Node source = getSource();
if (source == null) {
resultContainer.getErrors().add(
- new FieldError("source,referSource", "Kon geen source
node vinden met waardes: source=" + action.getSource()
- + " en referSource=" +
action.getReferSource()));
+ new
FieldError("source,referSource", "Kon geen source node vinden met waardes:
source="
+ +
action.getSource() + " en referSource=" + action.getReferSource()));
return;
}
Node destination = getDestination();
if (destination == null) {
resultContainer.getErrors().add(
- new FieldError("destination,referDestination", "Kon
geen destination node vinden met waardes: source="
- + action.getDestination() + " en
referDestination=" + action.getReferDestination()));
+ new
FieldError("destination,referDestination",
+ "Kon geen
destination node vinden met waardes: source=" + action.getDestination()
+
+ " en referDestination=" + action.getReferDestination()));
return;
}
String role = getRole();
@@ -57,33 +59,34 @@
if (sortField == null || "".equals(sortField)) {
if (role.equals("posrel")) {
sortField = "pos";
- }else {
- //perhaps the relation is of type posrel
+ } else {
+ // perhaps the relation is of type
posrel
RelationManager rmmm =
transactionalCloud.getRelationManager(role);
int builderNumber = rmmm.getIntValue("builder");
NodeManager nodeManager = (NodeManager)
transactionalCloud.getNode(builderNumber);
- if(nodeManager.getName().equals("posrel")) {
+ if
(nodeManager.getName().equals("posrel")) {
sortField = "pos";
- }else {
+ } else {
- //perhaps the relation manager is a descendant of
posrel
+ // perhaps the relation manager
is a descendant of posrel
NodeManager rm =
transactionalCloud.getNodeManager("posrel");
- if(rm != null) {
+ if (rm != null) {
NodeManagerList nml = rm.getDescendants();
- for(NodeManagerIterator i =
nml.nodeManagerIterator() ; i.hasNext(); ) {
- NodeManager nextNodeManager
=i.nextNodeManager();
+ for
(NodeManagerIterator i = nml.nodeManagerIterator(); i.hasNext();) {
+ NodeManager
nextNodeManager = i.nextNodeManager();
String name = nextNodeManager.getName();
- if(name.equals(role)) {
+ if
(name.equals(role)) {
sortField = "pos";
break;
}
}
}
- //TODO: we could also check if the relation is using
one of the Descendants as builder.
+ // TODO: we could also check if
the relation is using one of the Descendants as builder.
}
}
}
- String sortPosition = (action.getSortPosition().isEmpty() ? "" :
action.getSortPosition().toArray()[0].toString());
+ String sortPosition =
(action.getSortPosition().isEmpty() ? "" : action.getSortPosition().toArray()[0]
+ .toString());
Integer position = getPosition(sortField, sortPosition, source,
destination, role);
createRelation(source, destination, role, sortField, position);
}
@@ -91,17 +94,21 @@
/**
* checks for the fields that are needed to allow the creation of a
relation
+ *
* @return
*/
private boolean isValid() {
boolean result = true;
- if(action.getDestination().isEmpty() &&
action.getReferDestination().isEmpty()){
- resultContainer.getErrors().add(new FieldError("destination", "Als
je een relatie maakt moet je of destination of referDestination opgeven"));
+ if (action.getDestination().isEmpty() &&
action.getReferDestination().isEmpty()) {
+ resultContainer.getErrors().add(
+ new FieldError("destination",
+ "Als je een relatie
maakt moet je of destination of referDestination opgeven"));
result = false;
}
- if(action.getSource().isEmpty() && action.getReferSource().isEmpty()){
- resultContainer.getErrors().add(new FieldError("source", "Als je
een relatie maakt moet je of source of referSource opgeven"));
+ if (action.getSource().isEmpty() &&
action.getReferSource().isEmpty()) {
+ resultContainer.getErrors().add(
+ new FieldError("source", "Als je een
relatie maakt moet je of source of referSource opgeven"));
result = false;
}
return result;
@@ -123,9 +130,10 @@
try {
// find the lowest or highest relation number
- Query q = Queries.createQuery(transactionalCloud,
source.getNumber() + "", source.getNodeManager().getName() + "," + role + ","
- + destination.getNodeManager().getName(), role + "." +
sortField, null, role + "." + sortField, (sortPosition
- .equals("begin") ? "up" : "down"), null, false);
+ Query q = Queries.createQuery(transactionalCloud,
source.getNumber() + "", source.getNodeManager()
+ .getName()
+ + "," + role + "," +
destination.getNodeManager().getName(), role + "." + sortField, null, role
+ + "." + sortField,
(sortPosition.equals("begin") ? "up" : "down"), null, false);
q.setMaxNumber(1);
NodeList nl = transactionalCloud.getList(q);
if (nl.size() > 0) {
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs