You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/03/30 14:56:35 UTC
[06/22] isis git commit: ISIS-720: mothballing scimpi
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
new file mode 100644
index 0000000..020377d
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebugObjectView.java
@@ -0,0 +1,136 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.version.Version;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractObjectProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.view.display.FieldValue;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
+
+
+public class DebugObjectView extends AbstractObjectProcessor {
+
+ @Override
+ public void process(final Request request, final ObjectAdapter object) {
+ final String classString = " class=\"" + request.getOptionalProperty(CLASS, "form debug") + "\"";
+ final String objectLink = request.getOptionalProperty(OBJECT + "-" + LINK_VIEW, request.getViewPath());
+ // final String collectionLink = request.getOptionalProperty(COLLECTION + "-" + LINK_VIEW, request.getViewPath());
+ final String oddRowClass = request.getOptionalProperty(ODD_ROW_CLASS);
+ final String evenRowClass = request.getOptionalProperty(EVEN_ROW_CLASS);
+ final boolean showIcons = request.isRequested(SHOW_ICON, true);
+
+ ObjectSpecification specification = object.getSpecification();
+
+ request.appendHtml("<div" + classString + ">");
+ request.appendHtml("<div class=\"title\">");
+ request.appendAsHtmlEncoded(specification.getSingularName() + " - " + specification.getFullIdentifier());
+ request.appendHtml("</div>");
+
+ Version version = object.getVersion();
+ request.appendHtml("<div class=\"version\">");
+ request.appendAsHtmlEncoded("#" + version.sequence() + " - " + version.getUser() + " (" + version.getTime() + ")" );
+ request.appendHtml("</div>");
+
+ final List<ObjectAssociation> fields = specification.getAssociations(Contributed.EXCLUDED, ObjectAssociation.Filters.ALL);
+
+ int row = 1;
+ for (int i = 0; i < fields.size(); i++) {
+ final ObjectAssociation field = fields.get(i);
+ /*
+ * if (field.isVisible(IsisContext.getAuthenticationSession(), object).isVetoed()) { continue; }
+ */
+ String cls;
+ if (row++ % 2 == 1) {
+ cls = " class=\"field " + (oddRowClass == null ? ODD_ROW_CLASS : oddRowClass) + "\"";
+ } else {
+ cls = " class=\"field " + (evenRowClass == null ? EVEN_ROW_CLASS : evenRowClass) + "\"";
+ }
+ request.appendHtml("<div " + cls + "><span class=\"label\">");
+ request.appendAsHtmlEncoded(field.getName());
+ request.appendHtml(":</span>");
+
+ final boolean isNotParseable =
+ !fields.get(i).getSpecification().containsFacet(ParseableFacet.class);
+ LinkedObject linkedObject = null;
+ if (isNotParseable) {
+ // linkedObject = new LinkedObject(field.isOneToManyAssociation() ? collectionLink : objectLink);
+ linkedObject = new LinkedObject(objectLink);
+ }
+ addField(request, object, field, linkedObject, showIcons);
+
+ if (field.isOneToManyAssociation()) {
+ Collection collection = (Collection) field.get(object).getObject();
+ if (collection.size() == 0) {
+ request.appendHtml("[empty]");
+ } else {
+ // request.appendHtml(collection.size() + " elements");
+
+ request.appendHtml("<ol>");
+
+ for (Object element : collection) {
+ ObjectAdapter adapterFor = IsisContext.getPersistenceSession().getAdapterManager().getAdapterFor(element);
+ IsisContext.getPersistenceSession().resolveImmediately(adapterFor);
+
+ String id = request.getContext().mapObject(adapterFor, linkedObject.getScope(), Scope.INTERACTION);
+
+ request.appendHtml("<li class=\"element\">");
+ request.appendHtml("<a href=\"" + linkedObject.getForwardView() + "?" + linkedObject.getVariable() + "="
+ + id + request.getContext().encodedInteractionParameters() + "\">");
+ request.appendHtml(element.toString());
+ request.appendHtml("</a></li>");
+ }
+ request.appendHtml("</ol>");
+ }
+ } else {
+ FieldValue.write(request, object, field, linkedObject, "value", showIcons, 0);
+ }
+
+
+
+ request.appendHtml("</div>");
+ }
+ request.appendHtml("</div>");
+ }
+
+ protected void addField(
+ final Request request,
+ final ObjectAdapter object,
+ final ObjectAssociation field,
+ final LinkedObject linkedObject,
+ final boolean showIcons) {
+ }
+
+ @Override
+ public String getName() {
+ return "debug-object";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
new file mode 100644
index 0000000..795d272
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/DebuggerLink.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class DebuggerLink extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ if (request.getContext().isDebugDisabled()) {
+ request.skipUntilClose();
+ return;
+ }
+
+ final RequestContext context = request.getContext();
+ final Object result = context.getVariable(RequestContext.RESULT);
+ request.appendHtml("<div class=\"debug\">");
+ request.appendHtml("<a class=\"debug-link\" href=\"/debug/debug.shtml\" target=\"debug\" title=\"debug\" >...</a>");
+ if (result != null) {
+ request.appendHtml(" <a href=\"/debug/object.shtml?_result=" + result + "\" target=\"debug\" title=\"debug instance\">...</a>");
+ }
+ request.appendHtml(" <span class=\"debug-link\" onclick=\"$('#page-debug').toggle()\" alt=\"show/hide debug details\">...</span>");
+ request.appendHtml("</div>");
+
+ request.processUtilCloseTag();
+ }
+
+ @Override
+ public String getName() {
+ return "debugger";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
new file mode 100644
index 0000000..037812e
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Diagnostics.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.debug.DebugHtmlString;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class Diagnostics extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ if (request.getContext().isDebugDisabled()) {
+ return;
+ }
+
+ final String type = request.getOptionalProperty(TYPE, "page");
+ final boolean isForced = request.isRequested("force");
+ if (isForced || request.getContext().showDebugData()) {
+ request.appendHtml("<div class=\"debug\">");
+ if ("page".equals(type)) {
+ request.appendHtml("<pre>");
+ final RequestContext context = request.getContext();
+ request.appendHtml("URI: " + context.getUri());
+ request.appendHtml("\n");
+ request.appendHtml("File: " + context.fullFilePath(context.getResourceFile()));
+ final String result = (String) request.getContext().getVariable(RequestContext.RESULT);
+ if (result != null) {
+ request.appendHtml("\n");
+ request.appendHtml("Object: " + result);
+ }
+ request.appendHtml("</pre>");
+ } else if ("session".equals(type)) {
+ request.appendHtml("<pre>");
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ request.appendHtml("Session: " + session.getUserName() + " " + session.getRoles());
+ request.appendHtml("</pre>");
+ } else if ("variables".equals(type)) {
+ final RequestContext context = request.getContext();
+ final DebugHtmlString debug = new DebugHtmlString();
+ debug.appendln("", "");
+ context.append(debug, "variables");
+ debug.close();
+ request.appendHtml(debug.toString());
+ } else if ("processing".equals(type)) {
+ request.appendHtml("<pre>");
+ request.appendHtml(request.getContext().getDebugTrace());
+ request.appendHtml("</pre>");
+ } else {
+ request.appendHtml("<i>No such type " + type + "</i>");
+ }
+ request.appendHtml("</div>");
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "diagnostics";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
new file mode 100644
index 0000000..92db889
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Log.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class Log extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ String name = request.getRequiredProperty(NAME);
+ Logger logger = LoggerFactory.getLogger(name);
+
+ request.pushNewBuffer();
+ request.processUtilCloseTag();
+ final String message = request.popBuffer();
+ logger.info(message);
+ }
+
+ @Override
+ public String getName() {
+ return "log";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
new file mode 100644
index 0000000..66e2d6d
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/LogLevel.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class LogLevel extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+
+ String view = request.getOptionalProperty(VIEW, request.getViewPath());
+ view = request.getContext().fullFilePath(view);
+ final org.apache.log4j.Level level = org.apache.log4j.LogManager.getRootLogger().getLevel();
+ final boolean showSelector = request.isRequested(SHOW_SELECT, true);
+ if (showSelector) {
+ request.appendHtml("<form action=\"log.app\" type=\"post\" >");
+ request.appendHtml("<input type=\"hidden\" name=\"view\" value=\"" + view + "\" />");
+ request.appendHtml("<select name=\"level\">");
+ for (final org.apache.log4j.Level l : new org.apache.log4j.Level[] { org.apache.log4j.Level.OFF, org.apache.log4j.Level.FATAL, org.apache.log4j.Level.ERROR, org.apache.log4j.Level.WARN, org.apache.log4j.Level.INFO, org.apache.log4j.Level.DEBUG, org.apache.log4j.Level.TRACE }) {
+ final String settings = level + "\"" + (level == l ? " selected=\"selected\" " : "");
+ request.appendHtml("<option " + settings + ">" + l + "</option>");
+ }
+ request.appendHtml("<input type=\"submit\" value=\"Change Level\" />");
+ request.appendHtml("</select>");
+ request.appendHtml("</form>");
+ } else {
+ request.appendHtml(level.toString());
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "log-level";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
new file mode 100644
index 0000000..54ff196
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Members.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.applib.filter.Filters;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ActionType;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
+import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class Members extends AbstractElementProcessor {
+
+ // REVIEW: should provide this rendering context, rather than hardcoding.
+ // the net effect currently is that class members annotated with
+ // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+ // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
+ // for any other value for Where
+ private final Where where = Where.ANYWHERE;
+
+ @Override
+ public String getName() {
+ return "members";
+ }
+
+ @Override
+ public void process(final Request request) {
+ if (request.getContext().isDebugDisabled()) {
+ return;
+ }
+
+ final String id = request.getOptionalProperty(OBJECT);
+ final String fieldName = request.getOptionalProperty(FIELD);
+ request.appendHtml("<pre class=\"debug\">");
+ try {
+ ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ ObjectAssociation field = null;
+ if (fieldName != null) {
+ field = object.getSpecification().getAssociation(fieldName);
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ object = field.get(object);
+ }
+ request.processUtilCloseTag();
+
+ final ObjectSpecification specification = field == null ? object.getSpecification() : field.getSpecification();
+
+ request.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
+ final List<ObjectAssociation> fields = specification.getAssociations(Contributed.EXCLUDED);
+ for (final ObjectAssociation fld : fields) {
+ if (!fld.isAlwaysHidden()) {
+ request.appendHtml(" " + fld.getId() + " - '" + fld.getName() + "' -> " + fld.getSpecification().getSingularName() + (fld.isOneToManyAssociation() ? " (collection of)" : "") + "\n");
+ }
+ }
+ request.appendHtml(" --------------\n");
+ final List<ObjectAction> actions = specification.getObjectActions(
+ ActionType.USER, Contributed.INCLUDED, Filters.<ObjectAction>any());
+ ;
+ for (final ObjectAction action : actions) {
+ request.appendHtml(" " + action.getId() + " (");
+ boolean first = true;
+ for (final ObjectActionParameter parameter : action.getParameters()) {
+ if (!first) {
+ request.appendHtml(", ");
+ }
+ request.appendHtml(parameter.getSpecification().getSingularName());
+ first = false;
+ }
+ request.appendHtml(")" + " - '" + action.getName() + "'");
+ if (action.getSpecification() != null) {
+ request.appendHtml(" -> " + action.getSpecification().getSingularName() + ")");
+ }
+ request.appendHtml("\n");
+ }
+ } catch (final ScimpiException e) {
+ request.appendHtml("Debug failed: " + e.getMessage());
+ }
+ request.appendHtml("</pre>");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
new file mode 100644
index 0000000..895f9a6
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ShowDebug.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class ShowDebug extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ if (request.getContext().isDebugDisabled()) {
+ request.skipUntilClose();
+ } else {
+ request.processUtilCloseTag();
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "show-debug";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
new file mode 100644
index 0000000..0974fe4
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/Specification.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.core.commons.lang.StringExtensions;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+
+public class Specification extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ final RequestContext context = request.getContext();
+ if (context.isDebugDisabled()) {
+ return;
+ }
+
+ if (request.isRequested("always") || context.getDebug() == RequestContext.Debug.ON) {
+ request.appendHtml("<div class=\"debug\">");
+ request.appendHtml("<pre>");
+
+ final String id = request.getOptionalProperty("object");
+ final ObjectAdapter object = context.getMappedObjectOrResult(id);
+ final ObjectSpecification specification = object.getSpecification();
+ String type = request.getOptionalProperty(TYPE, "details");
+
+ if (type.equals("graph")) {
+ specificationGraph(request, specification, null, new ArrayList<ObjectSpecification>(), 0);
+ } else if (type.equals("details")) {
+ specificationDetails(request, specification);
+ } else {
+ request.appendHtml("invalid type: " + type);
+ }
+
+ request.appendHtml("</pre>");
+ request.appendHtml("</div>");
+ }
+ }
+
+ private void specificationDetails(final Request request, final ObjectSpecification specification) {
+ renderName(request, specification);
+ final List<ObjectAssociation> fields = specification.getAssociations(Contributed.EXCLUDED);
+ for (int i = 0; i < fields.size(); i++) {
+ request.appendHtml(" " + fields.get(i).getName() + " (" + fields.get(i).getSpecification().getSingularName()
+ + ") \n");
+ }
+ }
+
+ private void specificationGraph(
+ Request request,
+ ObjectSpecification specification,
+ String fieldName,
+ List<ObjectSpecification> processed,
+ int level) {
+ if (processed.contains(specification)) {
+ return;
+ }
+
+ request.appendHtml(StringExtensions.repeat(" ", level));
+ if (processed.contains(specification)) {
+ request.appendHtml("* ");
+ }
+ request.appendHtml(specification.getFullIdentifier());
+ if (fieldName != null) {
+ request.appendHtml(" (" + fieldName + ")");
+ }
+ request.appendHtml("\n");
+
+ if (processed.contains(specification)) {
+ return;
+ }
+ processed.add(specification);
+
+ final List<ObjectAssociation> fields = specification.getAssociations(Contributed.EXCLUDED);
+ for (int i = 0; i < fields.size(); i++) {
+ ObjectSpecification fieldSpecification = fields.get(i).getSpecification();
+ if (fieldSpecification.isValue()) {
+ continue;
+ }
+ specificationGraph(request, fieldSpecification, fields.get(i).getName(), processed, level + 1);
+ }
+ }
+
+ private void renderName(final Request request, final ObjectSpecification specification) {
+ request.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
+ }
+
+ @Override
+ public String getName() {
+ return "specification";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
new file mode 100644
index 0000000..65af85e
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/debug/ThrowException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.debug;
+
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class ThrowException extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ if (request.getContext().isDebugDisabled()) {
+ return;
+ }
+
+ final String message = request.getOptionalProperty("message", "Exception throw for testing purposes");
+ throw new IsisException(message);
+ }
+
+ @Override
+ public String getName() {
+ return "debug-exception";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java
new file mode 100644
index 0000000..e88f89a
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractFormView.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import java.util.List;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractObjectProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.view.HelpLink;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedFieldsBlock;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
+
+public abstract class AbstractFormView extends AbstractObjectProcessor {
+
+ @Override
+ public String checkFieldType(final ObjectAssociation objectField) {
+ return objectField.isOneToOneAssociation() ? null : "is not an object";
+ }
+
+ @Override
+ public void process(final Request request, final ObjectAdapter object) {
+ final LinkedFieldsBlock tag = new LinkedFieldsBlock();
+
+ if (object != null) {
+ final String id = request.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());
+ final String cls = request.getOptionalProperty(CLASS, "form");
+ final String classString = " id=\"" + id + "\" class=\"" + cls + "\"";
+ String title = request.getOptionalProperty(FORM_TITLE);
+ final String oddRowClass = request.getOptionalProperty(ODD_ROW_CLASS);
+ final String evenRowClass = request.getOptionalProperty(EVEN_ROW_CLASS);
+ final String labelDelimiter = request.getOptionalProperty(LABEL_DELIMITER, ":");
+ final boolean showIcons = request.isRequested(SHOW_ICON, showIconByDefault());
+ String linkAllView = request.getOptionalProperty(LINK_VIEW);
+
+ request.setBlockContent(tag);
+ request.processUtilCloseTag();
+
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ List<ObjectAssociation> associations = object.getSpecification().getAssociations(Contributed.EXCLUDED, ObjectAssociation.Filters.dynamicallyVisible(session, object, Where.OBJECT_FORMS));
+ final List<ObjectAssociation> fields = tag.includedFields(associations);
+ final LinkedObject[] linkFields = tag.linkedFields(fields);
+
+ if (linkAllView != null) {
+ linkAllView = request.getContext().fullUriPath(linkAllView);
+ for (int i = 0; i < linkFields.length; i++) {
+ final boolean isObject = fields.get(i).isOneToOneAssociation();
+ final boolean isNotParseable = !fields.get(i).getSpecification().containsFacet(ParseableFacet.class);
+ linkFields[i] = isObject && isNotParseable ? new LinkedObject(linkAllView) : null;
+ }
+ }
+
+ if (title == null) {
+ title = object.getSpecification().getSingularName();
+ } else if (title.equals("")) {
+ title = null;
+ }
+
+ write(request, object, fields, linkFields, classString, title, labelDelimiter, oddRowClass, evenRowClass, showIcons);
+ } else {
+ request.skipUntilClose();
+ }
+ }
+
+ private void write(
+ final Request request,
+ final ObjectAdapter object,
+ final List<ObjectAssociation> fields,
+ final LinkedObject[] linkFields,
+ final String classString,
+ final String title,
+ final String labelDelimiter,
+ final String oddRowClass,
+ final String evenRowClass,
+ final boolean showIcons) {
+ request.appendHtml("<div" + classString + ">");
+ if (title != null) {
+ request.appendHtml("<div class=\"title\">");
+ request.appendAsHtmlEncoded(title);
+ request.appendHtml("</div>");
+ HelpLink.append(request, object.getSpecification().getDescription(), object.getSpecification().getHelp());
+ }
+ int row = 1;
+ for (int i = 0; i < fields.size(); i++) {
+ final ObjectAssociation field = fields.get(i);
+ if (ignoreField(field)) {
+ continue;
+ }
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, Where.OBJECT_FORMS).isVetoed()) {
+ continue;
+ }
+
+ final String description = field.getDescription().equals("") ? "" : "title=\"" + field.getDescription() + "\"";
+ String cls;
+ if (row++ % 2 == 1) {
+ cls = " class=\"field " + (oddRowClass == null ? ODD_ROW_CLASS : oddRowClass) + "\"";
+ } else {
+ cls = " class=\"field " + (evenRowClass == null ? EVEN_ROW_CLASS : evenRowClass) + "\"";
+ }
+ request.appendHtml("<div " + cls + description + "><span class=\"label\">");
+ request.appendAsHtmlEncoded(field.getName());
+ request.appendHtml(labelDelimiter + "</span>");
+ final LinkedObject linkedObject = linkFields[i];
+ addField(request, object, field, linkedObject, showIcons);
+ HelpLink.append(request, field.getDescription(), field.getHelp());
+ request.appendHtml("</div>");
+ }
+ request.appendHtml("</div>");
+ }
+
+ protected void addField(final Request request, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedObject, final boolean showIcons) {
+ FieldValue.write(request, object, field, linkedObject, null, showIcons, 0);
+ }
+
+ protected boolean ignoreField(final ObjectAssociation objectField) {
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java
new file mode 100644
index 0000000..286d84d
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AbstractTableView.java
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import java.util.Iterator;
+import java.util.List;
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.Contributed;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.ResolveFieldUtil;
+import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public abstract class AbstractTableView extends AbstractElementProcessor {
+
+ // REVIEW: should provide this rendering context, rather than hardcoding.
+ // the net effect currently is that class members annotated with
+ // @Hidden(where=Where.ALL_TABLES) or @Disabled(where=Where.ALL_TABLES) will indeed
+ // be hidden from all tables but will be visible/enabled (perhaps incorrectly)
+ // if annotated with Where.PARENTED_TABLE or Where.STANDALONE_TABLE
+ private final Where where = Where.ALL_TABLES;
+
+ @Override
+ public void process(final Request request) {
+ final RequestContext context = request.getContext();
+
+ ObjectAdapter collection;
+ String parentObjectId = null;
+ boolean isFieldEditable = false;
+ final String field = request.getOptionalProperty(FIELD);
+ final String tableClass = request.getOptionalProperty(CLASS);
+ ObjectSpecification elementSpec;
+ String tableId;
+ if (field != null) {
+ final String objectId = request.getOptionalProperty(OBJECT);
+ final ObjectAdapter object = context.getMappedObjectOrResult(objectId);
+ if (object == null) {
+ throw new ScimpiException("No object for result or " + objectId);
+ }
+ final ObjectAssociation objectField = object.getSpecification().getAssociation(field);
+ if (!objectField.isOneToManyAssociation()) {
+ throw new ScimpiException("Field " + objectField.getId() + " is not a collection");
+ }
+ isFieldEditable = objectField.isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
+ ResolveFieldUtil.resolveField(object, objectField);
+ collection = objectField.get(object);
+ final TypeOfFacet facet = objectField.getFacet(TypeOfFacet.class);
+ elementSpec = facet.valueSpec();
+ parentObjectId = objectId == null ? context.mapObject(object, Scope.REQUEST) : objectId;
+ tableId = request.getOptionalProperty(ID, field);
+ } else {
+ final String id = request.getOptionalProperty(COLLECTION);
+ collection = context.getMappedObjectOrResult(id);
+ elementSpec = collection.getElementSpecification();
+ tableId = request.getOptionalProperty(ID, collection.getElementSpecification().getShortIdentifier());
+ }
+
+ final String summary = request.getOptionalProperty("summary");
+ final String rowClassesList = request.getOptionalProperty(ROW_CLASSES, ODD_ROW_CLASS + "|" + EVEN_ROW_CLASS);
+ String[] rowClasses = null;
+ if (rowClassesList.length() > 0) {
+ rowClasses = rowClassesList.split("[,|/]");
+ }
+
+ final List<ObjectAssociation> allFields = elementSpec.getAssociations(Contributed.EXCLUDED, ObjectAssociation.Filters.VISIBLE_AT_LEAST_SOMETIMES);
+ final TableContentWriter rowBuilder = createRowBuilder(request, context, isFieldEditable ? parentObjectId : null, allFields, collection);
+ write(request, collection, summary, rowBuilder, tableId, tableClass, rowClasses);
+
+ }
+
+ protected PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ protected abstract TableContentWriter createRowBuilder(final Request request, RequestContext context, final String parent, final List<ObjectAssociation> allFields, ObjectAdapter collection);
+
+ public static void write(
+ final Request request,
+ final ObjectAdapter collection,
+ final String summary,
+ final TableContentWriter rowBuilder,
+ final String tableId,
+ final String tableClass,
+ final String[] rowClasses) {
+ final RequestContext context = request.getContext();
+
+ final String summarySegment = summary == null ? "" : (" summary=\"" + summary + "\"");
+ final String idSegment = tableId == null ? "" : (" id=\"" + tableId + "\"");
+ final String classSegment = tableClass == null ? "" : (" class=\"" + tableClass + "\"");
+ request.appendHtml("<table" + idSegment + classSegment + summarySegment + ">");
+ rowBuilder.writeCaption(request);
+ rowBuilder.writeHeaders(request);
+ rowBuilder.writeFooters(request);
+
+ request.appendHtml("<tbody>");
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+ final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
+ int row = 1;
+ while (iterator.hasNext()) {
+ final ObjectAdapter element = iterator.next();
+
+ context.addVariable("row", "" + (row), Scope.REQUEST);
+ String cls = "";
+ if (rowClasses != null) {
+ cls = " class=\"" + rowClasses[row % rowClasses.length] + "\"";
+ }
+ request.appendHtml("<tr" + cls + ">");
+ rowBuilder.writeElement(request, context, element);
+ request.appendHtml("</tr>");
+ row++;
+ }
+ request.appendHtml("</tbody>");
+ request.appendHtml("</table>");
+
+ rowBuilder.tidyUp();
+ }
+
+ @Override
+ public String getName() {
+ return "table";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java
new file mode 100644
index 0000000..7076f70
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddMessage.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.core.commons.authentication.MessageBroker;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class AddMessage extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ request.pushNewBuffer();
+ request.processUtilCloseTag();
+ final String content = request.popBuffer();
+
+ final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ messageBroker.addMessage(content);
+ }
+
+ @Override
+ public String getName() {
+ return "add-message";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java
new file mode 100644
index 0000000..ac0d240
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/AddWarning.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.core.commons.authentication.MessageBroker;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class AddWarning extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ request.pushNewBuffer();
+ request.processUtilCloseTag();
+ final String content = request.popBuffer();
+
+ final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ messageBroker.addWarning(content);
+ }
+
+ @Override
+ public String getName() {
+ return "add-warning";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java
new file mode 100644
index 0000000..960997d
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Errors.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class Errors extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ final String cls = request.getOptionalProperty(CLASS);
+ final StringBuffer buffer = new StringBuffer();
+ write(request, cls, buffer);
+ if (buffer.length() > 0) {
+ request.appendHtml("<div class=\"error\">");
+ request.appendHtml(buffer.toString());
+ request.appendHtml("</div>");
+ }
+ }
+
+ public static void write(final Request request, String cls, final StringBuffer buffer) {
+ if (cls == null) {
+ cls = "error";
+ }
+ final String message = (String) request.getContext().getVariable("_error-message");
+ if (message != null) {
+ buffer.append(message);
+ }
+ final String details = (String) request.getContext().getVariable("_error-details");
+ if (details != null) {
+ buffer.append(details);
+ }
+
+ /*
+ * final MessageBroker messageBroker = IsisContext.getMessageBroker();
+ * final List<String> warnings = messageBroker.getWarnings(); for (final
+ * String warning : warnings) { buffer.append("<div class=\"" + cls +
+ * "\">" + warning + "</div>"); }
+ */
+ }
+
+ @Override
+ public String getName() {
+ return "errors";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java
new file mode 100644
index 0000000..f734ce2
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/Feedback.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class Feedback extends AbstractElementProcessor {
+
+ @Override
+ public void process(final Request request) {
+ final String cls = request.getOptionalProperty(CLASS);
+ final StringBuffer buffer = new StringBuffer();
+ Errors.write(request, cls, buffer);
+ Warnings.write(cls, buffer);
+ Messages.write(cls, buffer);
+ if (buffer.length() > 0) {
+ request.appendHtml("<div class=\"feedback\">");
+ request.appendHtml(buffer.toString());
+ request.appendHtml("</div>");
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "feedback";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java
new file mode 100644
index 0000000..32e2cd8
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldLabel.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class FieldLabel extends AbstractElementProcessor {
+
+ // REVIEW: should provide this rendering context, rather than hardcoding.
+ // the net effect currently is that class members annotated with
+ // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+ // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
+ // for any other value for Where
+ private final Where where = Where.ANYWHERE;
+
+ @Override
+ public void process(final Request request) {
+ final String id = request.getOptionalProperty(OBJECT);
+ final String fieldName = request.getRequiredProperty(FIELD);
+ final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
+ }
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ String delimiter = request.getOptionalProperty("delimiter");
+ if (delimiter == null) {
+ delimiter = ": ";
+ } else if (delimiter.equals("")) {
+ delimiter = null;
+ }
+ write(request, field, delimiter);
+ }
+
+ @Override
+ public String getName() {
+ return "label";
+ }
+
+ public static void write(final Request content, final ObjectAssociation field, final String delimiter) {
+ final String description = field.getDescription();
+ final String titleSegment = description == null || description.equals("") ? null : ("title=\"" + description + "\"");
+ content.appendHtml("<span class=\"label\"" + titleSegment + ">");
+ content.appendAsHtmlEncoded(field.getName());
+ if (delimiter != null) {
+ content.appendHtml("<span class=\"delimiter\">" + delimiter + "</span>");
+ }
+ content.appendHtml("</span>");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
new file mode 100644
index 0000000..3e84218
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/FieldValue.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.object.parseable.ParseableFacet;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.facets.value.booleans.BooleanValueFacet;
+import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
+
+public class FieldValue extends AbstractElementProcessor {
+
+ // REVIEW: should provide this rendering context, rather than hardcoding.
+ // the net effect currently is that class members annotated with
+ // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+ // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
+ // for any other value for Where
+ private final Where where = Where.ANYWHERE;
+
+ @Override
+ public void process(final Request request) {
+ final String className = request.getOptionalProperty(CLASS);
+ final String id = request.getOptionalProperty(OBJECT);
+ final String fieldName = request.getRequiredProperty(FIELD);
+ final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
+ }
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ final boolean isIconShowing = request.isRequested(SHOW_ICON, showIconByDefault());
+ final int truncateTo = Integer.valueOf(request.getOptionalProperty(TRUNCATE, "0")).intValue();
+
+ write(request, object, field, null, className, isIconShowing, truncateTo);
+ }
+
+ @Override
+ public String getName() {
+ return "field";
+ }
+
+ public static void write(final Request request, final ObjectAdapter object, final ObjectAssociation field, final LinkedObject linkedField, final String className, final boolean showIcon, final int truncateTo) {
+
+ final ObjectAdapter fieldReference = field.get(object);
+
+ if (fieldReference != null) {
+ final String classSection = "class=\"" + (className == null ? "value" : className) + "\"";
+ request.appendHtml("<span " + classSection + ">");
+ if (field.isOneToOneAssociation()) {
+ try {
+ IsisContext.getPersistenceSession().resolveImmediately(fieldReference);
+ } catch (final ObjectNotFoundException e) {
+ request.appendHtml(e.getMessage() + "</span>");
+ }
+ }
+
+ if (!field.getSpecification().containsFacet(ParseableFacet.class) && showIcon) {
+ request.appendHtml("<img class=\"small-icon\" src=\"" + request.getContext().imagePath(fieldReference) + "\" alt=\"" + field.getSpecification().getShortIdentifier() + "\"/>");
+ }
+
+ if (linkedField != null) {
+ final String id = request.getContext().mapObject(fieldReference, linkedField.getScope(), Scope.INTERACTION);
+ request.appendHtml("<a href=\"" + linkedField.getForwardView() + "?" + linkedField.getVariable() + "=" + id + request.getContext().encodedInteractionParameters() + "\">");
+ }
+ String value = fieldReference == null ? "" : fieldReference.titleString();
+ if (truncateTo > 0 && value.length() > truncateTo) {
+ value = value.substring(0, truncateTo) + "...";
+ }
+
+ // TODO figure out a better way to determine if boolean or a
+ // password
+ final ObjectSpecification spec = field.getSpecification();
+ final BooleanValueFacet facet = spec.getFacet(BooleanValueFacet.class);
+ if (facet != null) {
+ final boolean flag = facet.isSet(fieldReference);
+ final String valueSegment = flag ? " checked=\"checked\"" : "";
+ final String disabled = " disabled=\"disabled\"";
+ request.appendHtml("<input type=\"checkbox\"" + valueSegment + disabled + " />");
+ } else {
+ request.appendAsHtmlEncoded(value);
+ }
+
+ if (linkedField != null) {
+ request.appendHtml("</a>");
+ }
+ request.appendHtml("</span>");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
new file mode 100644
index 0000000..8a6ab16
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/GetField.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import java.text.DecimalFormat;
+import java.text.Format;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.facets.value.date.DateValueFacet;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.ScimpiException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+public class GetField extends AbstractElementProcessor {
+
+ // REVIEW: should provide this rendering context, rather than hardcoding.
+ // the net effect currently is that class members annotated with
+ // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+ // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
+ // for any other value for Where
+ private final Where where = Where.ANYWHERE;
+
+ @Override
+ public void process(final Request request) {
+ final String id = request.getOptionalProperty(OBJECT);
+ final String fieldName = request.getRequiredProperty(FIELD);
+ final ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ if (object == null) {
+ throw new ScimpiException("No object to get field for: " + fieldName + " - " + id);
+ }
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field == null) {
+ throw new ScimpiException("No field " + fieldName + " in " + object.getSpecification().getFullIdentifier());
+ }
+ final AuthenticationSession session = IsisContext.getAuthenticationSession();
+ if (field.isVisible(session, object, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+
+ String pattern = request.getOptionalProperty("decimal-format");
+ Format format = null;
+ if (pattern != null) {
+ format = new DecimalFormat(pattern);
+ }
+ pattern = request.getOptionalProperty("date-format");
+ if (pattern != null) {
+ format = new SimpleDateFormat(pattern);
+ }
+
+ final String name = request.getOptionalProperty(RESULT_NAME, fieldName);
+ final String scopeName = request.getOptionalProperty(SCOPE);
+ final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);
+
+ process(request, object, field, format, name, scope);
+ }
+
+ protected void process(final Request request, final ObjectAdapter object, final ObjectAssociation field, final Format format, final String name, final Scope scope) {
+ final ObjectAdapter fieldReference = field.get(object);
+ if (format != null && fieldReference.isValue()) {
+ final DateValueFacet facet = fieldReference.getSpecification().getFacet(DateValueFacet.class);
+ final Date date = facet.dateValue(fieldReference);
+ final String value = format.format(date);
+ request.appendDebug(" " + object + " -> " + value);
+ request.getContext().addVariable(name, Request.getEncoder().encoder(value), scope);
+ } else {
+ final String source = fieldReference == null ? "" : request.getContext().mapObject(fieldReference, scope);
+ request.appendDebug(" " + object + " -> " + source);
+ request.getContext().addVariable(name, source, scope);
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "get-field";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
new file mode 100644
index 0000000..aa3bfff
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/IncludeObject.java
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.isis.applib.annotation.Where;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractElementProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.ForbiddenException;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+
+/**
+ * Element to include another file that will display an object.
+ */
+public class IncludeObject extends AbstractElementProcessor {
+
+ // REVIEW: should provide this rendering context, rather than hardcoding.
+ // the net effect currently is that class members annotated with
+ // @Hidden(where=Where.ANYWHERE) or @Disabled(where=Where.ANYWHERE) will indeed
+ // be hidden/disabled, but will be visible/enabled (perhaps incorrectly)
+ // for any other value for Where
+ private final Where where = Where.ANYWHERE;
+
+ @Override
+ public void process(final Request request) {
+ final String path = request.getOptionalProperty("file");
+ String id = request.getOptionalProperty(OBJECT);
+ final String fieldName = request.getOptionalProperty(FIELD);
+ ObjectAdapter object = request.getContext().getMappedObjectOrResult(id);
+ if (fieldName != null) {
+ final ObjectAssociation field = object.getSpecification().getAssociation(fieldName);
+ if (field.isVisible(IsisContext.getAuthenticationSession(), object, where).isVetoed()) {
+ throw new ForbiddenException(field, ForbiddenException.VISIBLE);
+ }
+ object = field.get(object);
+ id = request.getContext().mapObject(object, Scope.REQUEST);
+ }
+
+ if (object != null) {
+ IsisContext.getPersistenceSession().resolveImmediately(object);
+ request.getContext().addVariable("_object", id, Scope.REQUEST);
+ importFile(request, path);
+ }
+ request.closeEmpty();
+ }
+
+ private static void importFile(final Request request, final String path) {
+ // TODO load in file via HtmlFileParser
+ final File file = new File(path);
+ BufferedReader reader = null;
+ try {
+ if (file.exists()) {
+ reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ String line;
+ while ((line = reader.readLine()) != null) {
+ request.appendHtml(line);
+ }
+ } else {
+ request.appendHtml("<P classs=\"error\">File " + path + " not found to import</P>");
+ }
+ } catch (final FileNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (final IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (final IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public String getName() {
+ return "include-object";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/2c7cfbfe/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java
----------------------------------------------------------------------
diff --git a/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java
new file mode 100644
index 0000000..3bd8352
--- /dev/null
+++ b/mothballed/component/viewer/scimpi/dispatcher/src/main/java/org/apache/isis/viewer/scimpi/dispatcher/view/display/ListView.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.viewer.scimpi.dispatcher.view.display;
+
+import java.util.Iterator;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.viewer.scimpi.dispatcher.AbstractObjectProcessor;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext;
+import org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext.Scope;
+import org.apache.isis.viewer.scimpi.dispatcher.processor.Request;
+import org.apache.isis.viewer.scimpi.dispatcher.view.field.LinkedObject;
+
+public class ListView extends AbstractObjectProcessor {
+
+ @Override
+ public String checkFieldType(final ObjectAssociation objectField) {
+ return objectField.isOneToManyAssociation() ? null : "is not a collection";
+ }
+
+ @Override
+ public void process(final Request request, final ObjectAdapter object) {
+ final String linkRowView = request.getOptionalProperty(LINK_VIEW);
+ final String linkObjectName = request.getOptionalProperty(ELEMENT_NAME, RequestContext.RESULT);
+ final String linkObjectScope = request.getOptionalProperty(SCOPE, Scope.INTERACTION.toString());
+ LinkedObject linkedRow = null;
+ if (linkRowView != null) {
+ linkedRow = new LinkedObject(linkObjectName, linkObjectScope, request.getContext().fullUriPath(linkRowView));
+ }
+ final String bulletType = request.getOptionalProperty("type");
+ write(request, object, linkedRow, bulletType);
+ }
+
+ public static void write(final Request request, final ObjectAdapter collection, final LinkedObject linkRow, final String bulletType) {
+
+ if (bulletType == null) {
+ request.appendHtml("<ol>");
+ } else {
+ request.appendHtml("<ul type=\"" + bulletType + "\">");
+ }
+
+ final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
+ final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
+ while (iterator.hasNext()) {
+ final ObjectAdapter element = iterator.next();
+
+ request.appendHtml("<li>");
+ if (linkRow != null) {
+ final Scope scope = linkRow == null ? Scope.INTERACTION : RequestContext.scope(linkRow.getScope());
+ RequestContext context = request.getContext();
+ final String rowId = context.mapObject(element, scope);
+ request.appendHtml("<a class=\"item-select\" href=\"" + linkRow.getForwardView() + "?" + linkRow.getVariable()
+ + "=" + rowId + context.encodedInteractionParameters() + "\">");
+ }
+ request.appendAsHtmlEncoded(element.titleString());
+ if (linkRow != null) {
+ request.appendHtml("</a>");
+ }
+
+ request.appendHtml("</li>\n");
+ }
+ if (bulletType == null) {
+ request.appendHtml("</ol>");
+ } else {
+ request.appendHtml("</ul>");
+ }
+
+ }
+
+ @Override
+ public String getName() {
+ return "list";
+ }
+
+}