incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1098951 [4/11] - in /incubator/isis/trunk/viewer: junit/src/main/java/org/apache/isis/viewer/junit/ junit/src/main/java/org/apache/isis/viewer/junit/internal/ junit/src/test/java/org/apache/isis/viewer/junit/ junit/src/test/java/org/apache...
Date Tue, 03 May 2011 07:53:11 GMT
Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/ActionAction.java Tue May  3 07:53:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.viewer.scimpi.dispatcher.action;
 
 import java.io.IOException;
@@ -46,7 +45,6 @@ import org.apache.isis.viewer.scimpi.dis
 import org.apache.isis.viewer.scimpi.dispatcher.edit.FormState;
 import org.apache.isis.viewer.scimpi.dispatcher.util.MethodsUtils;
 
-
 public class ActionAction implements Action {
 
     public static final String ACTION = "action";
@@ -60,100 +58,94 @@ public class ActionAction implements Act
      * REVIEW - this and EditAction are very similar - refactor out common code.
      */
     @Override
-    public void process(RequestContext context) throws IOException {
-        String objectId = context.getParameter("_" + OBJECT);
-        String version = context.getParameter("_" + VERSION);
-        String formId = context.getParameter("_" + FORM_ID);
-        String methodName = context.getParameter("_" + METHOD);
-        String override = context.getParameter("_" + RESULT_OVERRIDE);
+    public void process(final RequestContext context) throws IOException {
+        final String objectId = context.getParameter("_" + OBJECT);
+        final String version = context.getParameter("_" + VERSION);
+        final String formId = context.getParameter("_" + FORM_ID);
+        final String methodName = context.getParameter("_" + METHOD);
+        final String override = context.getParameter("_" + RESULT_OVERRIDE);
         String resultName = context.getParameter("_" + RESULT_NAME);
-        String message = context.getParameter("_" + MESSAGE);
+        final String message = context.getParameter("_" + MESSAGE);
         resultName = resultName == null ? RequestContext.RESULT : resultName;
-        
+
         FormState entryState = null;
         try {
-            ObjectAdapter object = MethodsUtils.findObject(context, objectId);
-            // FIXME need to find method based on the set of parameters. otherwise overloaded method may be incorrectly selected.
-            ObjectAction action = MethodsUtils.findAction(object, methodName);
+            final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
+            // FIXME need to find method based on the set of parameters. otherwise overloaded method may be incorrectly
+            // selected.
+            final ObjectAction action = MethodsUtils.findAction(object, methodName);
             entryState = validateParameters(context, action, object);
 
-            AuthenticationSession session = context.getSession();
+            final AuthenticationSession session = context.getSession();
             if (session == null && action.isUsable(new UserlessSession(), object).isVetoed()) {
                 throw new NotLoggedInException();
             }
-            
-            object.checkLock(context.getVersion(version));
-       /*     
-            Version adapterVersion = object.getVersion();
-            if (adapterVersion.different(context.getVersion(version))) {
-                
-                IsisContext.getMessageBroker().addMessage("The " + object.getSpecification().getSingularName() + " was edited " +
-                        "by another user (" + adapterVersion.getUser() +  "). Please  make your changes based on their changes.");
 
-                entryState.setForm(objectId + ":" + methodName);
-                context.addVariable(ENTRY_FIELDS, entryState, Scope.REQUEST);
-                context.addVariable(resultName, objectId, Scope.REQUEST);
-                if (override != null) {
-                    context.addVariable(resultName, override, Scope.REQUEST);
-                }   
-                final String error = entryState.getError();
-                if (error != null) {
-                    context.addVariable(RequestContext.ERROR, error, Scope.REQUEST);
-                }
-                
-                String view = context.getParameter(ERRORS);
-                context.setRequestPath(view, Dispatcher.ACTION);
-
-            } else    */         
+            object.checkLock(context.getVersion(version));
+            /*
+             * Version adapterVersion = object.getVersion(); if (adapterVersion.different(context.getVersion(version)))
+             * {
+             * 
+             * IsisContext.getMessageBroker().addMessage("The " + object.getSpecification().getSingularName() +
+             * " was edited " + "by another user (" + adapterVersion.getUser() +
+             * "). Please  make your changes based on their changes.");
+             * 
+             * entryState.setForm(objectId + ":" + methodName); context.addVariable(ENTRY_FIELDS, entryState,
+             * Scope.REQUEST); context.addVariable(resultName, objectId, Scope.REQUEST); if (override != null) {
+             * context.addVariable(resultName, override, Scope.REQUEST); } final String error = entryState.getError();
+             * if (error != null) { context.addVariable(RequestContext.ERROR, error, Scope.REQUEST); }
+             * 
+             * String view = context.getParameter(ERRORS); context.setRequestPath(view, Dispatcher.ACTION);
+             * 
+             * } else
+             */
             if (entryState.isValid()) {
-                boolean hasResult = invokeMethod(context, resultName, object, action, entryState);
+                final boolean hasResult = invokeMethod(context, resultName, object, action, entryState);
                 String view = context.getParameter(hasResult ? "_" + VIEW : "_" + VOID);
-                
-             //   context.clearVariables(Scope.REQUEST);
 
-                int questionMark = view == null ? -1 : view.indexOf("?");
+                // context.clearVariables(Scope.REQUEST);
+
+                final int questionMark = view == null ? -1 : view.indexOf("?");
                 if (questionMark > -1) {
-                    String params[] = view.substring(questionMark + 1).split("&"); 
-                    for (String param : params) { 
-                        int equals = param.indexOf("="); 
-                        context.addVariable(param.substring(0, equals), param.substring(equals + 1), Scope.REQUEST); 
-                        view = view.substring(0, questionMark); 
+                    final String params[] = view.substring(questionMark + 1).split("&");
+                    for (final String param : params) {
+                        final int equals = param.indexOf("=");
+                        context.addVariable(param.substring(0, equals), param.substring(equals + 1), Scope.REQUEST);
+                        view = view.substring(0, questionMark);
                     }
                 }
                 context.setRequestPath(view);
                 if (message != null) {
-                    MessageBroker messageBroker = IsisContext.getMessageBroker();
+                    final MessageBroker messageBroker = IsisContext.getMessageBroker();
                     messageBroker.addMessage(message);
                 }
                 if (override != null) {
                     context.addVariable(resultName, override, Scope.REQUEST);
-                }                
+                }
                 if (context.getVariable(resultName) == null) {
                     context.addVariable(resultName, objectId, Scope.REQUEST);
-                }                
+                }
             } else {
                 entryState.setForm(formId);
                 context.addVariable(ENTRY_FIELDS, entryState, Scope.REQUEST);
                 context.addVariable(resultName, objectId, Scope.REQUEST);
                 if (override != null) {
                     context.addVariable(resultName, override, Scope.REQUEST);
-                }   
+                }
                 final String error = entryState.getError();
                 /*
-                if (error != null) {
-                    context.addVariable(RequestContext.ERROR, error, Scope.REQUEST);
-                }
-                */
-                
-                String view = context.getParameter("_" + ERRORS);
+                 * if (error != null) { context.addVariable(RequestContext.ERROR, error, Scope.REQUEST); }
+                 */
+
+                final String view = context.getParameter("_" + ERRORS);
                 context.setRequestPath(view, Dispatcher.ACTION);
-                
-                MessageBroker messageBroker = IsisContext.getMessageBroker();
+
+                final MessageBroker messageBroker = IsisContext.getMessageBroker();
                 messageBroker.addWarning(error);
             }
 
-        } catch (ConcurrencyException e) {
-            
+        } catch (final ConcurrencyException e) {
+
             IsisContext.getMessageBroker().addMessage(e.getMessage());
 
             entryState.setForm(formId);
@@ -161,17 +153,16 @@ public class ActionAction implements Act
             context.addVariable(resultName, objectId, Scope.REQUEST);
             if (override != null) {
                 context.addVariable(resultName, override, Scope.REQUEST);
-            }   
+            }
             final String error = entryState.getError();
             if (error != null) {
                 context.addVariable(RequestContext.ERROR, error, Scope.REQUEST);
             }
-            
-            String view = context.getParameter("_" + ERRORS);
+
+            final String view = context.getParameter("_" + ERRORS);
             context.setRequestPath(view, Dispatcher.ACTION);
-            
-            
-        } catch (RuntimeException e) {
+
+        } catch (final RuntimeException e) {
             IsisContext.getMessageBroker().getMessages();
             IsisContext.getMessageBroker().getWarnings();
             IsisContext.getUpdateNotifier().clear();
@@ -180,69 +171,65 @@ public class ActionAction implements Act
         }
     }
 
-    private boolean invokeMethod(
-            RequestContext context,
-            String variable,
-            ObjectAdapter object,
-            ObjectAction action,
-            FormState entryState) {
-
-        ObjectAdapter[] parameters = getParameters(action, entryState);
-        String scopeName = context.getParameter("_" + SCOPE);
-        Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
+    private boolean invokeMethod(final RequestContext context, final String variable, final ObjectAdapter object,
+        final ObjectAction action, final FormState entryState) {
+
+        final ObjectAdapter[] parameters = getParameters(action, entryState);
+        final String scopeName = context.getParameter("_" + SCOPE);
+        final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
         return MethodsUtils.runMethod(context, action, object, parameters, variable, scope);
     }
 
-    private ObjectAdapter[] getParameters(ObjectAction action, FormState entryState) {
-        int parameterCount = action.getParameterCount();
-        ObjectAdapter[] parameters = new ObjectAdapter[parameterCount];
+    private ObjectAdapter[] getParameters(final ObjectAction action, final FormState entryState) {
+        final int parameterCount = action.getParameterCount();
+        final ObjectAdapter[] parameters = new ObjectAdapter[parameterCount];
         for (int i = 0; i < parameterCount; i++) {
             parameters[i] = entryState.getField(parameterName(i)).getValue();
         }
         return parameters;
     }
 
-    private FormState validateParameters(RequestContext context, ObjectAction action, ObjectAdapter object) {
-        FormState formState = new FormState();
-        List<ObjectActionParameter> parameters2 = action.getParameters();
-        int parameterCount = action.getParameterCount();
+    private FormState validateParameters(final RequestContext context, final ObjectAction action,
+        final ObjectAdapter object) {
+        final FormState formState = new FormState();
+        final List<ObjectActionParameter> parameters2 = action.getParameters();
+        final int parameterCount = action.getParameterCount();
         for (int i = 0; i < parameterCount; i++) {
-            String fieldName = parameterName(i);
+            final String fieldName = parameterName(i);
             String newEntry = context.getParameter(fieldName);
-            
-            if(newEntry != null && newEntry.equals("-OTHER-")) {
+
+            if (newEntry != null && newEntry.equals("-OTHER-")) {
                 newEntry = context.getParameter(fieldName + "-other");
             }
-            
+
             if (newEntry == null) {
                 // TODO figure out a better way to determine if boolean or a password
-                ObjectSpecification spec = parameters2.get(i).getSpecification();
+                final ObjectSpecification spec = parameters2.get(i).getSpecification();
                 if (spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(boolean.class))
-                        || spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(Boolean.class))) {
+                    || spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(Boolean.class))) {
                     newEntry = FALSE;
                 } else {
                     newEntry = "";
                 }
             }
-            FieldEditState fieldState = formState.createField(fieldName, newEntry);
+            final FieldEditState fieldState = formState.createField(fieldName, newEntry);
             Consent consent = null;
 
-            
             if (!parameters2.get(i).isOptional() && newEntry.equals("")) {
                 consent = new Veto(parameters2.get(i).getName() + " required");
                 formState.setError("Not all fields have been set");
 
-            } else  if (parameters2.get(i).getSpecification().getFacet(ParseableFacet.class) != null) {
+            } else if (parameters2.get(i).getSpecification().getFacet(ParseableFacet.class) != null) {
                 try {
-                    ParseableFacet facet = parameters2.get(i).getSpecification().getFacet(ParseableFacet.class);
-                    String message = parameters2.get(i).isValid(object, newEntry); 
-                    if (message != null) { 
-                        consent = new Veto(message); 
+                    final ParseableFacet facet = parameters2.get(i).getSpecification().getFacet(ParseableFacet.class);
+                    final String message = parameters2.get(i).isValid(object, newEntry);
+                    if (message != null) {
+                        consent = new Veto(message);
                         formState.setError("Not all fields are valid");
-                    } 
-                    ObjectAdapter entry = facet.parseTextEntry(null, newEntry);
+                    }
+                    final ObjectAdapter entry = facet.parseTextEntry(null, newEntry);
                     fieldState.setValue(entry);
-                } catch (TextEntryParseException e) {
+                } catch (final TextEntryParseException e) {
                     consent = new Veto(e.getMessage());
                     formState.setError("Not all fields are valid");
                 }
@@ -253,26 +240,27 @@ public class ActionAction implements Act
                 fieldState.setError(consent.getReason());
             }
         }
-        
+
         if (formState.isValid()) {
-            ObjectAdapter[] parameters = getParameters(action, formState);
-            Consent consent = action.isProposedArgumentSetValid(object, parameters);
+            final ObjectAdapter[] parameters = getParameters(action, formState);
+            final Consent consent = action.isProposedArgumentSetValid(object, parameters);
             if (consent != null && consent.isVetoed()) {
                 formState.setError(consent.getReason());
             }
         }
-        
+
         return formState;
     }
 
-    public static String parameterName(int index) {
+    public static String parameterName(final int index) {
         return PARAMETER + (index + 1);
     }
 
     @Override
-    public void init() {}
+    public void init() {
+    }
 
     @Override
-    public void debug(DebugBuilder debug) {}
+    public void debug(final DebugBuilder debug) {
+    }
 }
-

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/Attributes.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/Attributes.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/Attributes.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/Attributes.java Tue May  3 07:53:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.viewer.scimpi.dispatcher.action;
 
 import java.util.Enumeration;
@@ -27,60 +26,59 @@ import org.apache.isis.viewer.scimpi.dis
 import org.htmlparser.Attribute;
 import org.htmlparser.nodes.TagNode;
 
-
 public class Attributes {
     private static final String TRUE = " true yes on ";
     private static final String FALSE = " false no off ";
     private final TagNode tagNode;
     private final RequestContext context;
 
-    public Attributes(TagNode tagNode, RequestContext context) {
+    public Attributes(final TagNode tagNode, final RequestContext context) {
         this.tagNode = tagNode;
         this.context = context;
     }
 
-    public boolean isPropertySet(String name) {
-        String attribute = tagNode.getAttribute(name);
+    public boolean isPropertySet(final String name) {
+        final String attribute = tagNode.getAttribute(name);
         int end = attribute.length() - 1;
-        int pos = attribute.indexOf(':');
-        end = pos == -1 ? end : pos; 
-        String variabelName = attribute.substring(2, end);
-        Object value = context.getVariable(variabelName);
+        final int pos = attribute.indexOf(':');
+        end = pos == -1 ? end : pos;
+        final String variabelName = attribute.substring(2, end);
+        final Object value = context.getVariable(variabelName);
         return value != null;
-//        return attribute != null && !context.replaceVariables(attribute).equals("");
+        // return attribute != null && !context.replaceVariables(attribute).equals("");
     }
 
-    public boolean isPropertySpecified(String name) {
-        String attribute = tagNode.getAttribute(name);
+    public boolean isPropertySpecified(final String name) {
+        final String attribute = tagNode.getAttribute(name);
         return attribute != null;
     }
-    
-    public String getOptionalProperty(String name, boolean ensureVariablesExists) {
+
+    public String getOptionalProperty(final String name, final boolean ensureVariablesExists) {
         return getOptionalProperty(name, null, ensureVariablesExists);
     }
 
-    public String getOptionalProperty(String name, String defaultValue, boolean ensureVariablesExists) {
-        String attribute = tagNode.getAttribute(name);
+    public String getOptionalProperty(final String name, final String defaultValue, final boolean ensureVariablesExists) {
+        final String attribute = tagNode.getAttribute(name);
         return attribute == null ? defaultValue : context.replaceVariables(attribute);
     }
 
-    public String getRequiredProperty(String name, boolean ensureVariablesExists) {
-        String attribute = tagNode.getAttribute(name);
+    public String getRequiredProperty(final String name, final boolean ensureVariablesExists) {
+        final String attribute = tagNode.getAttribute(name);
         if (attribute == null) {
             throw new RequiredPropertyException("Missing property: " + name);
         } else if (attribute.equals("")) {
             throw new RequiredPropertyException("Property not set: " + name);
-       } else {
-           return context.replaceVariables(attribute);
+        } else {
+            return context.replaceVariables(attribute);
         }
     }
-    
-    public String[] getPropertyNames(String excluding[]) {
-        Vector attributes = tagNode.getAttributesEx();
-        String[] names = new String[attributes.size()];
+
+    public String[] getPropertyNames(final String excluding[]) {
+        final Vector attributes = tagNode.getAttributesEx();
+        final String[] names = new String[attributes.size()];
         int i = 0;
-        names: for (Enumeration e = attributes.elements(); e.hasMoreElements(); ) {
-            String name = ((Attribute) e.nextElement()).getName();
+        names: for (final Enumeration e = attributes.elements(); e.hasMoreElements();) {
+            final String name = ((Attribute) e.nextElement()).getName();
             if (name == null) {
                 continue;
             }
@@ -93,22 +91,23 @@ public class Attributes {
                 names[i++] = name;
             }
         }
-        
-        String[] array = new String[i];
+
+        final String[] array = new String[i];
         System.arraycopy(names, 0, array, 0, i);
         return array;
     }
 
-    public String toString() { 
-        return tagNode.toHtml(); //getAttributesEx().toString(); 
-    } 
-    
-    public boolean isRequested(String name) {
+    @Override
+    public String toString() {
+        return tagNode.toHtml(); // getAttributesEx().toString();
+    }
+
+    public boolean isRequested(final String name) {
         return isRequested(name, false);
     }
 
-    public boolean isRequested(String name, boolean defaultValue) {
-        String flag = getOptionalProperty(name, true);
+    public boolean isRequested(final String name, final boolean defaultValue) {
+        final String flag = getOptionalProperty(name, true);
         if (flag == null) {
             return defaultValue;
         } else {
@@ -116,11 +115,11 @@ public class Attributes {
         }
     }
 
-    public static boolean isTrue(String flag) {
-        String value = " " + flag.toLowerCase().trim() + " ";
+    public static boolean isTrue(final String flag) {
+        final String value = " " + flag.toLowerCase().trim() + " ";
         if (TRUE.indexOf(value) >= 0) {
             return true;
-        } else if  (FALSE.indexOf(value) >= 0) {
+        } else if (FALSE.indexOf(value) >= 0) {
             return false;
         } else {
             throw new PropertyException("Illegal flag value: " + flag);
@@ -128,4 +127,3 @@ public class Attributes {
     }
 
 }
-

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/PropertyException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/PropertyException.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/PropertyException.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/PropertyException.java Tue May  3 07:53:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.viewer.scimpi.dispatcher.action;
 
 import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
@@ -30,18 +29,16 @@ public class PropertyException extends S
         super();
     }
 
-    public PropertyException(String message, Throwable cause) {
+    public PropertyException(final String message, final Throwable cause) {
         super(message, cause);
     }
 
-    public PropertyException(String message) {
+    public PropertyException(final String message) {
         super(message);
     }
 
-    public PropertyException(Throwable cause) {
+    public PropertyException(final Throwable cause) {
         super(cause);
     }
 
 }
-
-

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RequiredPropertyException.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RequiredPropertyException.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RequiredPropertyException.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/action/RequiredPropertyException.java Tue May  3 07:53:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.viewer.scimpi.dispatcher.action;
 
 import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
@@ -29,18 +28,16 @@ public class RequiredPropertyException e
         super();
     }
 
-    public RequiredPropertyException(String message, Throwable cause) {
+    public RequiredPropertyException(final String message, final Throwable cause) {
         super(message, cause);
     }
 
-    public RequiredPropertyException(String message) {
+    public RequiredPropertyException(final String message) {
         super(message);
     }
 
-    public RequiredPropertyException(Throwable cause) {
+    public RequiredPropertyException(final Throwable cause) {
         super(cause);
     }
 
 }
-
-

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultOidObjectMapping.java Tue May  3 07:53:06 2011
@@ -46,76 +46,83 @@ import org.apache.log4j.Logger;
 import org.json.JSONException;
 import org.json.JSONObject;
 
-
 public class DefaultOidObjectMapping implements ObjectMapping {
     private static final Logger LOG = Logger.getLogger(DefaultOidObjectMapping.class);
     private final Map<String, TransientObjectMapping> requestTransients = new HashMap<String, TransientObjectMapping>();
     private final Map<String, TransientObjectMapping> sessionTransients = new HashMap<String, TransientObjectMapping>();
     private Class<? extends Oid> oidType;
 
-    public void append(DebugBuilder debug) {
+    @Override
+    public void append(final DebugBuilder debug) {
         append(debug, requestTransients, "request");
         append(debug, sessionTransients, "session");
     }
 
-    protected void append(DebugBuilder debug, Map<String, TransientObjectMapping> transients, String type) {
-        Iterator<String> ids = new HashSet(transients.keySet()).iterator();
+    protected void append(final DebugBuilder debug, final Map<String, TransientObjectMapping> transients,
+        final String type) {
+        final Iterator<String> ids = new HashSet(transients.keySet()).iterator();
         if (ids.hasNext()) {
             debug.appendTitle("Transient objects (" + type + ")");
             while (ids.hasNext()) {
-                String key = ids.next();
+                final String key = ids.next();
                 debug.appendln(key, transients.get(key).debug());
             }
         }
     }
 
-    public void appendMappings(DebugBuilder request) {}
+    @Override
+    public void appendMappings(final DebugBuilder request) {
+    }
 
+    @Override
     public void clear() {
         requestTransients.clear();
 
-        List<String> remove = new ArrayList<String>();
-        for (String id : sessionTransients.keySet()) {
+        final List<String> remove = new ArrayList<String>();
+        for (final String id : sessionTransients.keySet()) {
             if (!sessionTransients.get(id).getOid().isTransient()) {
                 remove.add(id);
                 sessionTransients.put(id, null);
             }
         }
-        for (String id : remove) {
+        for (final String id : remove) {
             sessionTransients.remove(id);
         }
     }
 
+    @Override
     public void endSession() {
         sessionTransients.clear();
     }
 
-    public String mapTransientObject(ObjectAdapter object) {
+    @Override
+    public String mapTransientObject(final ObjectAdapter object) {
         try {
-            List<ObjectAdapter> savedObject = new ArrayList<ObjectAdapter>();
-            JSONObject data = encodeTransientData(object, savedObject);
-            return "D" + data.toString(4); //StringEscapeUtils.escapeHtml(data.toString(4));
-        } catch (JSONException e) {
+            final List<ObjectAdapter> savedObject = new ArrayList<ObjectAdapter>();
+            final JSONObject data = encodeTransientData(object, savedObject);
+            return "D" + data.toString(4); // StringEscapeUtils.escapeHtml(data.toString(4));
+        } catch (final JSONException e) {
             throw new ScimpiException(e);
         }
     }
 
-    private JSONObject encodeTransientData(ObjectAdapter object, List<ObjectAdapter> savedObject) throws JSONException {
+    private JSONObject encodeTransientData(final ObjectAdapter object, final List<ObjectAdapter> savedObject)
+        throws JSONException {
         if (savedObject.contains(object)) {
             return null;
         }
         savedObject.add(object);
 
-        JSONObject data = new JSONObject();
-        ObjectSpecification specification = object.getSpecification();
+        final JSONObject data = new JSONObject();
+        final ObjectSpecification specification = object.getSpecification();
         data.put("_class", specification.getFullIdentifier());
 
-        Oid oid = object.getOid();
+        final Oid oid = object.getOid();
         String encodedOid;
         if (oid instanceof AggregatedOid) {
-            AggregatedOid aoid = (AggregatedOid) oid;
-            Oid parentOid = aoid.getParentOid();
-            String aggregatedId = aoid.getId();
+            final AggregatedOid aoid = (AggregatedOid) oid;
+            final Oid parentOid = aoid.getParentOid();
+            final String aggregatedId = aoid.getId();
             encodedOid = Long.toString(((SerialOid) parentOid).getSerialNo(), 16) + "@" + aggregatedId;
         } else if (oid instanceof SerialOid) {
             encodedOid = Long.toString(((SerialOid) oid).getSerialNo(), 16);
@@ -125,24 +132,24 @@ public class DefaultOidObjectMapping imp
 
         data.put("_id", encodedOid);
 
-        for (ObjectAssociation association : specification.getAssociations()) {
-            ObjectAdapter fieldValue = association.get(object);
-            String fieldName = association.getId();
+        for (final ObjectAssociation association : specification.getAssociations()) {
+            final ObjectAdapter fieldValue = association.get(object);
+            final String fieldName = association.getId();
             if (fieldValue == null) {
                 data.put(fieldName, (Object) null);
             } else if (association.getSpecification().isEncodeable()) {
-                EncodableFacet encodeableFacet = fieldValue.getSpecification().getFacet(EncodableFacet.class);
+                final EncodableFacet encodeableFacet = fieldValue.getSpecification().getFacet(EncodableFacet.class);
                 data.put(fieldName, encodeableFacet.toEncodedString(fieldValue));
             } else if (association instanceof OneToManyAssociation) {
-                List<JSONObject> collection = new ArrayList<JSONObject>();
-                CollectionFacet facet = fieldValue.getSpecification().getFacet(CollectionFacet.class);
-                for (ObjectAdapter element : facet.iterable(fieldValue)) {
+                final List<JSONObject> collection = new ArrayList<JSONObject>();
+                final CollectionFacet facet = fieldValue.getSpecification().getFacet(CollectionFacet.class);
+                for (final ObjectAdapter element : facet.iterable(fieldValue)) {
                     collection.add(encodeTransientData(element, savedObject));
                 }
                 data.put(fieldName, collection);
             } else {
                 if (fieldValue.isTransient() || fieldValue.isAggregated()) {
-                    JSONObject saveData = encodeTransientData(fieldValue, savedObject);
+                    final JSONObject saveData = encodeTransientData(fieldValue, savedObject);
                     if (saveData == null) {
                         data.put(fieldName, mapObject(fieldValue, Scope.INTERACTION));
                     } else {
@@ -156,24 +163,25 @@ public class DefaultOidObjectMapping imp
         return data;
     }
 
-    public String mapObject(ObjectAdapter inObject, Scope scope) {
+    @Override
+    public String mapObject(final ObjectAdapter inObject, final Scope scope) {
         // TODO need to ensure that transient objects are remapped each time so that any changes are added to
         // session data
         // continue work here.....here
 
         ObjectAdapter object = inObject;
 
-        Oid oid = object.getOid();
+        final Oid oid = object.getOid();
         if (oidType == null) {
             oidType = oid.getClass();
         }
 
         String encodedOid;
         if (oid instanceof AggregatedOid) {
-            AggregatedOid aoid = (AggregatedOid) oid;
-            Oid parentOid = aoid.getParentOid();
+            final AggregatedOid aoid = (AggregatedOid) oid;
+            final Oid parentOid = aoid.getParentOid();
             object = IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(parentOid);
-            String aggregatedId = aoid.getId();
+            final String aggregatedId = aoid.getId();
             encodedOid = Long.toString(((SerialOid) parentOid).getSerialNo(), 16) + "@" + aggregatedId;
         } else if (oid instanceof SerialOid) {
             encodedOid = Long.toString(((SerialOid) oid).getSerialNo(), 16);
@@ -181,8 +189,9 @@ public class DefaultOidObjectMapping imp
             encodedOid = IsisContext.getPersistenceSession().getOidGenerator().getOidStringifier().enString(oid);
         }
 
-        boolean isTransient = object.isTransient();
-        String transferableId = (isTransient ? "T" : "P") + object.getSpecification().getFullIdentifier() + "@" + encodedOid;
+        final boolean isTransient = object.isTransient();
+        final String transferableId =
+            (isTransient ? "T" : "P") + object.getSpecification().getFullIdentifier() + "@" + encodedOid;
         LOG.debug("encoded " + oid + " as " + transferableId + " ~ " + encodedOid);
 
         if (inObject.isTransient()) {
@@ -190,7 +199,7 @@ public class DefaultOidObjectMapping imp
             // TODO cache these in requests so that Mementos are only created once.
             // TODO if Transient/Interaction then return state; other store state in session an return OID
             // string
-            TransientObjectMapping mapping = new TransientObjectMapping(inObject);
+            final TransientObjectMapping mapping = new TransientObjectMapping(inObject);
             if (scope == Scope.REQUEST) {
                 requestTransients.put(transferableId, mapping);
             } else if (scope == Scope.INTERACTION || scope == Scope.SESSION) {
@@ -202,68 +211,68 @@ public class DefaultOidObjectMapping imp
         return transferableId;
     }
 
-    public ObjectAdapter mappedTransientObject(String data) {
-        String objectData = data; //StringEscapeUtils.unescapeHtml(data);
+    @Override
+    public ObjectAdapter mappedTransientObject(final String data) {
+        final String objectData = data; // StringEscapeUtils.unescapeHtml(data);
         LOG.debug("data" + objectData);
 
         try {
-            JSONObject jsonObject = new JSONObject(objectData);
-            ObjectAdapter object = restoreTransientObject(jsonObject);
+            final JSONObject jsonObject = new JSONObject(objectData);
+            final ObjectAdapter object = restoreTransientObject(jsonObject);
             return object;
-        } catch (JSONException e) {
+        } catch (final JSONException e) {
             throw new ScimpiException("Problem reading data: " + data, e);
         }
     }
 
-    private ObjectAdapter restoreTransientObject(JSONObject jsonObject) throws JSONException {
-        String cls = jsonObject.getString("_class");
-        String id = jsonObject.getString("_id");
+    private ObjectAdapter restoreTransientObject(final JSONObject jsonObject) throws JSONException {
+        final String cls = jsonObject.getString("_class");
+        final String id = jsonObject.getString("_id");
 
         ObjectAdapter object;
-        ObjectSpecification specification = IsisContext.getSpecificationLoader().loadSpecification(cls);
+        final ObjectSpecification specification = IsisContext.getSpecificationLoader().loadSpecification(cls);
         if (specification.isAggregated() && !specification.isCollection()) {
-            String[] split = id.split("@");
-            SerialOid parentOid = SerialOid.createTransient(Long.parseLong(split[0], 16));
-            AggregatedOid oid = new AggregatedOid(parentOid, split[1]);
+            final String[] split = id.split("@");
+            final SerialOid parentOid = SerialOid.createTransient(Long.parseLong(split[0], 16));
+            final AggregatedOid oid = new AggregatedOid(parentOid, split[1]);
             object = IsisContext.getPersistenceSession().recreateAdapter(oid, specification);
         } else {
             object = mappedObject("T" + cls + "@" + id);
         }
 
-        for (ObjectAssociation association : specification.getAssociations()) {
-            String fieldName = association.getId();
+        for (final ObjectAssociation association : specification.getAssociations()) {
+            final String fieldName = association.getId();
 
-            Object fieldValue = jsonObject.has(fieldName) ? jsonObject.get(fieldName) : null;
+            final Object fieldValue = jsonObject.has(fieldName) ? jsonObject.get(fieldName) : null;
 
             if (association.getSpecification().isEncodeable()) {
                 if (fieldValue == null) {
                     ((OneToOneAssociation) association).initAssociation(object, null);
                 } else {
-                    EncodableFacet encodeableFacet = association.getSpecification().getFacet(EncodableFacet.class);
-                    ObjectAdapter fromEncodedString = encodeableFacet.fromEncodedString((String) fieldValue);
+                    final EncodableFacet encodeableFacet =
+                        association.getSpecification().getFacet(EncodableFacet.class);
+                    final ObjectAdapter fromEncodedString = encodeableFacet.fromEncodedString((String) fieldValue);
                     ((OneToOneAssociation) association).initAssociation(object, fromEncodedString);
                 }
             } else if (association instanceof OneToManyAssociation) {
-                List<JSONObject> collection = new ArrayList<JSONObject>();
+                final List<JSONObject> collection = new ArrayList<JSONObject>();
                 if (!collection.isEmpty()) {
                     throw new ScimpiException("Unexpected association for transient object " + association);
                 }
                 /*
-                CollectionFacet facet = fieldValue.getSpecification().getFacet(CollectionFacet.class);
-                for (ObjectAdapter element : facet.iterable(fieldValue)) {
-                   collection.add(saveData(element, savedObject));
-                }
-                data.put(fieldName, collection);
-                */
+                 * CollectionFacet facet = fieldValue.getSpecification().getFacet(CollectionFacet.class); for
+                 * (ObjectAdapter element : facet.iterable(fieldValue)) { collection.add(saveData(element,
+                 * savedObject)); } data.put(fieldName, collection);
+                 */
             } else {
                 if (fieldValue == null) {
                     ((OneToOneAssociation) association).initAssociation(object, null);
                 } else {
                     if (fieldValue instanceof JSONObject) {
-                        ObjectAdapter fieldObject = restoreTransientObject((JSONObject) fieldValue);
+                        final ObjectAdapter fieldObject = restoreTransientObject((JSONObject) fieldValue);
                         ((OneToOneAssociation) association).initAssociation(object, fieldObject);
                     } else {
-                        ObjectAdapter field = mappedObject((String) fieldValue);
+                        final ObjectAdapter field = mappedObject((String) fieldValue);
                         ((OneToOneAssociation) association).initAssociation(object, field);
                     }
                 }
@@ -272,30 +281,33 @@ public class DefaultOidObjectMapping imp
         return object;
     }
 
-    public ObjectAdapter mappedObject(String id) {
-        char type = id.charAt(0);
+    @Override
+    public ObjectAdapter mappedObject(final String id) {
+        final char type = id.charAt(0);
         if ((type == 'T')) {
             TransientObjectMapping mapping = sessionTransients.get(id);
             if (mapping == null) {
                 mapping = requestTransients.get(id);
             }
             if (mapping == null) {
-                String[] split = id.split("@");
-                ObjectSpecification spec = IsisContext.getSpecificationLoader().loadSpecification(split[0].substring(1));
-                Object pojo = spec.createObject(CreationMode.NO_INITIALIZE);
-                String oidData = split[1];
-                SerialOid oid = SerialOid.createTransient(Long.valueOf(oidData, 16).longValue());
+                final String[] split = id.split("@");
+                final ObjectSpecification spec =
+                    IsisContext.getSpecificationLoader().loadSpecification(split[0].substring(1));
+                final Object pojo = spec.createObject(CreationMode.NO_INITIALIZE);
+                final String oidData = split[1];
+                final SerialOid oid = SerialOid.createTransient(Long.valueOf(oidData, 16).longValue());
                 return IsisContext.getPersistenceSession().recreateAdapter(oid, pojo);
             }
-            ObjectAdapter mappedTransientObject = mapping.getObject();
+            final ObjectAdapter mappedTransientObject = mapping.getObject();
             LOG.debug("retrieved " + mappedTransientObject.getOid() + " for " + id);
             return mappedTransientObject;
         } else {
-            String[] split = id.split("@");
-            ObjectSpecification spec = IsisContext.getSpecificationLoader().loadSpecification(split[0].substring(1));
+            final String[] split = id.split("@");
+            final ObjectSpecification spec =
+                IsisContext.getSpecificationLoader().loadSpecification(split[0].substring(1));
 
             try {
-                String oidData = split[1];
+                final String oidData = split[1];
                 LOG.debug("decoding " + oidData);
 
                 ObjectAdapter loadObject;
@@ -305,7 +317,7 @@ public class DefaultOidObjectMapping imp
                     oidType = IsisContext.getPersistenceSession().getServices().get(0).getOid().getClass();
                 }
                 if (split.length > 2) {
-                    SerialOid parentOid = SerialOid.createPersistent(Long.parseLong(oidData, 16));
+                    final SerialOid parentOid = SerialOid.createPersistent(Long.parseLong(oidData, 16));
                     oid = new AggregatedOid(parentOid, split[2]);
                     IsisContext.getPersistenceSession().loadObject(parentOid, spec);
                     loadObject = IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(oid);
@@ -318,21 +330,23 @@ public class DefaultOidObjectMapping imp
                 }
 
                 return loadObject;
-            } catch (SecurityException e) {
+            } catch (final SecurityException e) {
                 throw new IsisException(e);
             }
         }
     }
 
+    @Override
     public void reloadIdentityMap() {
-        Iterator<TransientObjectMapping> mappings = sessionTransients.values().iterator();
+        final Iterator<TransientObjectMapping> mappings = sessionTransients.values().iterator();
         while (mappings.hasNext()) {
-            TransientObjectMapping mapping = mappings.next();
+            final TransientObjectMapping mapping = mappings.next();
             mapping.reload();
         }
     }
 
-    public void unmapObject(ObjectAdapter object, Scope scope) {
+    @Override
+    public void unmapObject(final ObjectAdapter object, final Scope scope) {
         sessionTransients.remove(object.getOid());
         requestTransients.remove(object.getOid());
     }

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultVersionMapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultVersionMapping.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultVersionMapping.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/DefaultVersionMapping.java Tue May  3 07:53:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.viewer.scimpi.dispatcher.context;
 
 import org.apache.isis.core.metamodel.adapter.version.SerialNumberVersion;
@@ -25,17 +24,17 @@ import org.apache.isis.core.metamodel.ad
 
 public class DefaultVersionMapping implements VersionMapping {
 
-    public String mapVersion(Version version) {
-        //SerialNumberVersion v = (SerialNumberVersion) version;
-        //return Long.toHexString(v.getSequence());
-    	return version.sequence();
+    @Override
+    public String mapVersion(final Version version) {
+        // SerialNumberVersion v = (SerialNumberVersion) version;
+        // return Long.toHexString(v.getSequence());
+        return version.sequence();
     }
 
-    public Version getVersion(String id) {
-        Long sequence = Long.valueOf(id, 16);
+    @Override
+    public Version getVersion(final String id) {
+        final Long sequence = Long.valueOf(id, 16);
         return new SerialNumberVersion(sequence, null, null);
     }
 
 }
-
-

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/IndirectObjectMapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/IndirectObjectMapping.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/IndirectObjectMapping.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/IndirectObjectMapping.java Tue May  3 07:53:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.viewer.scimpi.dispatcher.context;
 
 import java.util.HashMap;
@@ -31,7 +30,6 @@ import org.apache.isis.core.commons.exce
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
 
-
 public class IndirectObjectMapping implements ObjectMapping {
     private final Map<Scope, Map<String, Mapping>> scopedMappings = new LinkedHashMap<Scope, Map<String, Mapping>>();
     private int nextId = 0;
@@ -48,67 +46,72 @@ public class IndirectObjectMapping imple
         return String.valueOf(nextId);
     }
 
+    @Override
     public void endSession() {
         scopedMappings.get(Scope.SESSION).clear();
         nextId = 0;
     }
 
+    @Override
     public void reloadIdentityMap() {
         reloadIdentityMap(Scope.GLOBAL);
         reloadIdentityMap(Scope.SESSION);
         reloadIdentityMap(Scope.INTERACTION);
-        
-        Map<String, Mapping> map = scopedMappings.get(Scope.INTERACTION);
+
+        final Map<String, Mapping> map = scopedMappings.get(Scope.INTERACTION);
         scopedMappings.put(Scope.REQUEST, map);
         scopedMappings.put(Scope.INTERACTION, new HashMap<String, Mapping>());
     }
 
-    private void reloadIdentityMap(Scope scope) {
-        Map<String, Mapping> map = scopedMappings.get(scope);
-        Iterator<String> ids = map.keySet().iterator();
+    private void reloadIdentityMap(final Scope scope) {
+        final Map<String, Mapping> map = scopedMappings.get(scope);
+        final Iterator<String> ids = map.keySet().iterator();
         while (ids.hasNext()) {
-            String key = ids.next();
-            Mapping mapping = map.get(key);
+            final String key = ids.next();
+            final Mapping mapping = map.get(key);
             mapping.reload();
         }
     }
 
+    @Override
     public void clear() {
         scopedMappings.get(Scope.REQUEST).clear();
     }
 
-    public void unmapObject(ObjectAdapter object, Scope scope) {
-        String id = mapObject(object, scope);
+    @Override
+    public void unmapObject(final ObjectAdapter object, final Scope scope) {
+        final String id = mapObject(object, scope);
         scopedMappings.get(scope).remove(id);
     }
 
-    public void appendMappings(DebugBuilder debug) {
+    @Override
+    public void appendMappings(final DebugBuilder debug) {
         appendMappings(debug, scopedMappings.get(Scope.INTERACTION));
     }
 
-    private void appendMappings(DebugBuilder debug, Map<String, Mapping> map) {
-        Iterator<String> names = map.keySet().iterator();
+    private void appendMappings(final DebugBuilder debug, final Map<String, Mapping> map) {
+        final Iterator<String> names = map.keySet().iterator();
         while (names.hasNext()) {
-            String id = names.next();
-            ObjectAdapter object = mappedObject(id);
+            final String id = names.next();
+            final ObjectAdapter object = mappedObject(id);
             debug.appendln(id, object);
         }
     }
 
-    private void appendMappings(DebugBuilder debug, Scope scope) {
+    private void appendMappings(final DebugBuilder debug, final Scope scope) {
         debug.appendTitle("Objects for " + scope);
-        Map<String, Mapping> map = scopedMappings.get(scope);
-        Iterator<String> ids = new TreeSet(map.keySet()).iterator();
+        final Map<String, Mapping> map = scopedMappings.get(scope);
+        final Iterator<String> ids = new TreeSet(map.keySet()).iterator();
         if (!ids.hasNext()) {
             debug.appendln("None", "");
         }
         while (ids.hasNext()) {
-            String key = ids.next();
+            final String key = ids.next();
             debug.appendln(key, map.get(key).debug());
         }
     }
 
-    private Mapping createMapping(ObjectAdapter adapter) {
+    private Mapping createMapping(final ObjectAdapter adapter) {
         if (adapter.getResolveState().isTransient()) {
             return new TransientObjectMapping(adapter);
         } else {
@@ -121,11 +124,12 @@ public class IndirectObjectMapping imple
      * 
      * @see org.apache.isis.webapp.context.ObjectMapping#mappedObject(java.lang.String)
      */
-    public ObjectAdapter mappedObject(String id) {
-        Iterator<Map<String, Mapping>> iterator = scopedMappings.values().iterator();
+    @Override
+    public ObjectAdapter mappedObject(final String id) {
+        final Iterator<Map<String, Mapping>> iterator = scopedMappings.values().iterator();
         while (iterator.hasNext()) {
-            Map<String, Mapping> map = iterator.next();
-            Mapping mapping = map.get(id);
+            final Map<String, Mapping> map = iterator.next();
+            final Mapping mapping = map.get(id);
             if (mapping != null) {
                 return mapping.getObject();
             }
@@ -133,38 +137,39 @@ public class IndirectObjectMapping imple
         return null;
     }
 
-    public String mapObject(ObjectAdapter obj, Scope scope) {
+    @Override
+    public String mapObject(final ObjectAdapter obj, final Scope scope) {
         ObjectAdapter object;
-        object = (ObjectAdapter) obj;
-        Mapping mapping = createMapping(object);
-        
+        object = obj;
+        final Mapping mapping = createMapping(object);
+
         boolean changeScope = false;
-        for (Scope s : scopedMappings.keySet()) {
-            Map<String, Mapping> map = scopedMappings.get(s);
+        for (final Scope s : scopedMappings.keySet()) {
+            final Map<String, Mapping> map = scopedMappings.get(s);
             if (map.containsValue(mapping)) {
-                String id = findMapping(map, mapping);
+                final String id = findMapping(map, mapping);
                 if (changeScope) {
                     map.remove(id);
                     scopedMappings.get(scope).put(id, mapping);
                 }
                 return id;
             }
-            
+
             if (s == scope) {
                 changeScope = true;
             }
         }
-        
-        Map<String, Mapping> map = scopedMappings.get(scope);
-        String id = obj.getSpecification().getShortIdentifier() + "@" + nextId();
+
+        final Map<String, Mapping> map = scopedMappings.get(scope);
+        final String id = obj.getSpecification().getShortIdentifier() + "@" + nextId();
         map.put(id, mapping);
         return id;
     }
 
-    private String findMapping(Map<String, Mapping> map, Mapping mapping) {
-        Iterator<String> ids = map.keySet().iterator();
+    private String findMapping(final Map<String, Mapping> map, final Mapping mapping) {
+        final Iterator<String> ids = map.keySet().iterator();
         while (ids.hasNext()) {
-            String key = ids.next();
+            final String key = ids.next();
             if (map.get(key).equals(mapping)) {
                 return key;
             }
@@ -173,7 +178,8 @@ public class IndirectObjectMapping imple
         return null;
     }
 
-    public void append(DebugBuilder debug) {
+    @Override
+    public void append(final DebugBuilder debug) {
         debug.appendln("Next ID", nextId);
 
         appendMappings(debug, Scope.GLOBAL);
@@ -182,11 +188,13 @@ public class IndirectObjectMapping imple
         appendMappings(debug, Scope.REQUEST);
     }
 
-    public ObjectAdapter mappedTransientObject(String substring) {
+    @Override
+    public ObjectAdapter mappedTransientObject(final String substring) {
         throw new NotYetImplementedException();
     }
 
-    public String mapTransientObject(ObjectAdapter object) {
+    @Override
+    public String mapTransientObject(final ObjectAdapter object) {
         throw new NotYetImplementedException();
     }
 

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Mapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Mapping.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Mapping.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/Mapping.java Tue May  3 07:53:06 2011
@@ -17,7 +17,6 @@
  *  under the License.
  */
 
-
 package org.apache.isis.viewer.scimpi.dispatcher.context;
 
 import org.apache.isis.core.commons.debug.DebugString;
@@ -36,40 +35,45 @@ interface Mapping {
     String debug();
 
     void reload();
-    
+
     void update();
 }
 
 class TransientObjectMapping implements Mapping {
-    private Oid oid;
+    private final Oid oid;
     private Memento memento;
 
-    public TransientObjectMapping(ObjectAdapter adapter) {
+    public TransientObjectMapping(final ObjectAdapter adapter) {
         oid = adapter.getOid();
         Assert.assertTrue("OID is for persistent", oid.isTransient());
         Assert.assertTrue("adapter is for persistent", adapter.isTransient());
         memento = new Memento(adapter);
     }
 
+    @Override
     public ObjectAdapter getObject() {
         return IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(oid);
     }
 
+    @Override
     public Oid getOid() {
         return oid;
     }
 
+    @Override
     public String debug() {
-        DebugString debug = new DebugString();
+        final DebugString debug = new DebugString();
         memento.debug(debug);
         return debug.toString();
     }
 
+    @Override
     public void reload() {
         memento.recreateObject();
     }
 
-    public boolean equals(Object obj) {
+    @Override
+    public boolean equals(final Object obj) {
         if (obj == this) {
             return true;
         }
@@ -80,58 +84,67 @@ class TransientObjectMapping implements 
         return false;
     }
 
+    @Override
     public int hashCode() {
         return oid.hashCode();
     }
 
+    @Override
     public void update() {
-        memento = new Memento((ObjectAdapter) getObject());
+        memento = new Memento(getObject());
     }
 }
 
 class PersistentObjectMapping implements Mapping {
-    private Oid oid;
-    private ObjectSpecification spec;
+    private final Oid oid;
+    private final ObjectSpecification spec;
 
-    public PersistentObjectMapping(ObjectAdapter object) {
+    public PersistentObjectMapping(final ObjectAdapter object) {
         this.oid = object.getOid();
         this.spec = object.getSpecification();
     }
 
+    @Override
     public Oid getOid() {
         return oid;
     }
 
+    @Override
     public String debug() {
-        return oid + "  " + spec.getShortIdentifier() + "  " + IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(oid);
+        return oid + "  " + spec.getShortIdentifier() + "  "
+            + IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(oid);
     }
 
+    @Override
     public ObjectAdapter getObject() {
-    	if (!IsisContext.inTransaction()) {
-    		throw new IllegalStateException(getClass().getSimpleName() + " requires transaction in order to load");
-    	}
+        if (!IsisContext.inTransaction()) {
+            throw new IllegalStateException(getClass().getSimpleName() + " requires transaction in order to load");
+        }
         return IsisContext.getPersistenceSession().loadObject(oid, spec);
     }
 
+    @Override
     public void reload() {
         if (IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(oid) == null) {
             IsisContext.getPersistenceSession().recreateAdapter(oid, spec);
         }
     }
 
-    public boolean equals(Object obj) {
+    @Override
+    public boolean equals(final Object obj) {
         if (obj == this) {
             return true;
         }
 
         if (obj instanceof PersistentObjectMapping) {
-            PersistentObjectMapping other = (PersistentObjectMapping) obj;
+            final PersistentObjectMapping other = (PersistentObjectMapping) obj;
             return oid.equals(other.oid) && spec == other.spec;
         }
 
         return false;
     }
 
+    @Override
     public int hashCode() {
         int hash = 37;
         hash = hash * 17 + oid.hashCode();
@@ -139,7 +152,8 @@ class PersistentObjectMapping implements
         return hash;
     }
 
-    public void update() {}
+    @Override
+    public void update() {
+    }
 
 }
-

Modified: incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ObjectMapping.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ObjectMapping.java?rev=1098951&r1=1098950&r2=1098951&view=diff
==============================================================================
--- incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ObjectMapping.java (original)
+++ incubator/isis/trunk/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/context/ObjectMapping.java Tue May  3 07:53:06 2011
@@ -17,14 +17,12 @@
  *  under the License.
  */
 
-
 package org.apache.isis.viewer.scimpi.dispatcher.context;
 
 import org.apache.isis.core.commons.debug.DebugBuilder;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
 import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
 
-
 public interface ObjectMapping {
 
     void endSession();
@@ -47,6 +45,4 @@ public interface ObjectMapping {
 
     void append(DebugBuilder debug);
 
-
-
 }



Mime
View raw message