Skip to content

Commit

Permalink
Configure SysConfig prefix from 00_qi XML file
Browse files Browse the repository at this point in the history
With this change, we don't need to create views such as PermissionsView
that just adds a constructor. One just needs to add three properties
to the view configuration:

   * name
   * title
   * prefix

i.e.:

    name: permissions
    title: Permissions
    prefix: perm.

full example:

  <view route="permissions" class="org.jpos.qi.sysconfig.SysConfigView" perm="sysadmin" sidebar="system">
    <property name="entityName" value="permission"/>

    <property name="name" value="permissions"/>
    <property name="prefix" value="perm." />
    <property name="title" value="Permissions" />

    <attribute name="id" read-only="true" required="true"/>
    <attribute name="value" regex="&TEXT_PATTERN;" required="true"/>
  </view>
  • Loading branch information
ar committed Jan 19, 2018
1 parent 0685a12 commit 0b473d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
import com.vaadin.ui.Component;
import com.vaadin.ui.Grid;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import org.apache.commons.lang3.StringUtils;
import org.jpos.core.Configuration;
import org.jpos.ee.BLException;
import org.jpos.ee.SysConfig;
import org.jpos.qi.QI;
import org.jpos.qi.QIEntityView;
import org.jpos.qi.QIHelper;

Expand Down Expand Up @@ -138,4 +141,17 @@ public boolean canRemove() {
public String getPrefix() {
return prefix;
}

@Override
public void setConfiguration (Configuration cfg) {
super.setConfiguration(cfg);
this.prefix = cfg.get("prefix", prefix);
String title = cfg.get("title", null);
if (title != null)
setTitle("<strong>" + title + "</strong>");
String name = cfg.get("name", null);
if (name != null) {
setGeneralRoute("/" + name);
}
}
}
11 changes: 10 additions & 1 deletion modules/testbed/src/dist/deploy/00_qi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,20 @@
<attribute name="id" required="true" read-only="true" regex="&WORD_PATTERN;" length="64" />
<attribute name="value" regex="&TEXT_PATTERN;" required="true"/>
</view>
<view route="permissions" class="org.jpos.qi.sysconfig.PermissionView" perm="sysadmin" sidebar="system">
<!--<view route="permissions" class="org.jpos.qi.sysconfig.PermissionView" perm="sysadmin" sidebar="system">-->
<!--<property name="entityName" value="permission"/>-->
<!--<attribute name="id" read-only="true" required="true"/>-->
<!--<attribute name="value" regex="&TEXT_PATTERN;" required="true"/>-->
<!--</view>-->
<view route="permissions" class="org.jpos.qi.sysconfig.SysConfigView" perm="sysadmin" sidebar="system">
<property name="name" value="permissions"/>
<property name="entityName" value="permission"/>
<property name="prefix" value="perm." />
<property name="title" value="Permissions" />
<attribute name="id" read-only="true" required="true"/>
<attribute name="value" regex="&TEXT_PATTERN;" required="true"/>
</view>

<view route="users" class="org.jpos.qi.eeuser.UsersView" perm="users.write" sidebar="system">
<property name="entityName" value="user"/>
<attribute name="id" field="false" required="true"/>
Expand Down

0 comments on commit 0b473d1

Please sign in to comment.