2
Fork 0

Split backend to backend api.

This commit is contained in:
Willem Cazander 2014-03-02 19:45:22 +01:00
parent 4bd244f4e5
commit a13719f008
116 changed files with 1029 additions and 815 deletions

View file

@ -0,0 +1,178 @@
package net.forwardfire.vasc.opt.editor;
import java.util.ArrayList;
import java.util.List;
import net.forwardfire.vasc.backend.AbstractVascBackend;
import net.forwardfire.vasc.backend.VascBackendException;
import net.forwardfire.vasc.backend.VascBackendState;
import net.forwardfire.vasc.backend.VascEntryFieldValue;
import net.forwardfire.vasc.backend.VascEntryRecordCreator;
import net.forwardfire.vasc.backend.data.BeanVascEntryFieldValue;
import net.forwardfire.vasc.backend.data.BeanVascEntryRecordCreator;
import net.forwardfire.vasc.core.VascController;
import net.forwardfire.vasc.core.VascEntry;
import net.forwardfire.vasc.core.VascEntryControllerLocal;
import net.forwardfire.vasc.core.VascEntryField;
import net.forwardfire.vasc.core.VascEntryFieldLocal;
import net.forwardfire.vasc.core.VascEntryFieldSet;
import net.forwardfire.vasc.core.VascEntryFieldSetLocal;
import net.forwardfire.vasc.core.VascEntryLinkLocal;
import net.forwardfire.vasc.core.VascEntryListOption;
import net.forwardfire.vasc.core.VascEntryListOptionLocal;
import net.forwardfire.vasc.core.VascEntryLocal;
import net.forwardfire.vasc.core.VascEntryLink;
import net.forwardfire.vasc.impl.DefaultVascEntry;
import net.forwardfire.vasc.impl.DefaultVascEntryField;
import net.forwardfire.vasc.impl.DefaultVascEntryFieldSet;
import net.forwardfire.vasc.impl.DefaultVascEntryLink;
public class VirtualVascBackend extends AbstractVascBackend {
private VascController vascController = null;
private String vascType = "entry";
private String entryId = null;
public List<Object> execute(VascBackendState state) throws VascBackendException {
List<Object> result = new ArrayList<Object>(100);
entryId = (String)state.getDataParameter("entry_id");
if ("entry".equals(vascType)) {
for (String id:vascController.getVascEntryController().getVascEntryIds()) {
result.add(vascController.getVascEntryController().getVascEntryById(id));
}
} else if ("field".equals(vascType)) {
if (entryId!=null) {
VascEntry ve = vascController.getVascEntryController().getVascEntryById(entryId);
result.addAll(ve.getVascEntryFields());
}
} else if ("fieldset".equals(vascType)) {
if (entryId!=null) {
VascEntry ve = vascController.getVascEntryController().getVascEntryById(entryId);
result.addAll(ve.getVascEntryFieldSets());
}
} else if ("linkentries".equals(vascType)) {
if (entryId!=null) {
VascEntry ve = vascController.getVascEntryController().getVascEntryById(entryId);
result.addAll(ve.getVascEntryLinks());
}
} else if ("listoptions".equals(vascType)) {
if (entryId!=null) {
VascEntry ve = vascController.getVascEntryController().getVascEntryById(entryId);
result.addAll(ve.getVascEntryListOptions());
}
}
return result;
}
public void persist(Object object) throws VascBackendException {
edit(object,false,true);
}
public Object merge(Object object) throws VascBackendException {
return edit(object,true,true);
}
public void delete(Object object) throws VascBackendException {
edit(object,true,false);
}
public Object edit(Object object,boolean removeReal,boolean addEdit) throws VascBackendException {
if (object instanceof VascEntry) {
entryId = ((VascEntry)object).getId();
}
VascEntryLocal veReal = (VascEntryLocal)((VascEntryControllerLocal)vascController.getVascEntryController()).getMasterVascEntryById(entryId);
if ("entry".equals(vascType)) {
} else if ("field".equals(vascType)) {
VascEntryFieldLocal vef = (VascEntryFieldLocal)object;
if (removeReal) {
VascEntryField vefReal = veReal.getVascEntryFieldById(vef.getId());
veReal.removeVascEntryField((VascEntryFieldLocal)vefReal);
}
if (addEdit) {
veReal.addVascEntryField(vef);
}
} else if ("fieldset".equals(vascType)) {
VascEntryFieldSetLocal vefs = (VascEntryFieldSetLocal)object;
if (removeReal) {
VascEntryFieldSet vefsReal = veReal.getVascEntryFieldSetById(vefs.getId());
veReal.removeVascEntryFieldSet((VascEntryFieldSetLocal)vefsReal);
}
if (addEdit) {
veReal.addVascEntryFieldSet(vefs);
}
} else if ("linkentries".equals(vascType)) {
VascEntryLinkLocal vefs = (VascEntryLinkLocal)object;
if (removeReal) {
VascEntryLink vefsReal = veReal.getVascEntryLinkById(vefs.getId());
veReal.removeVascEntryLink((VascEntryLinkLocal)vefsReal);
}
if (addEdit) {
veReal.addVascEntryLink(vefs);
}
} else if ("listoptions".equals(vascType)) {
VascEntryListOptionLocal vef = (VascEntryListOptionLocal)object;
if (removeReal) {
VascEntryListOption vefReal = veReal.getVascEntryListOptionById(vef.getId());
veReal.removeVascEntryListOption((VascEntryListOptionLocal)vefReal);
}
if (addEdit) {
veReal.addVascEntryListOption(vef);
}
}
return object;
}
public VascEntryFieldValue provideVascEntryFieldValue() {
return new BeanVascEntryFieldValue();
}
public VascEntryRecordCreator provideVascEntryRecordCreator() {
if ("entry".equals(vascType)) {
return new BeanVascEntryRecordCreator(DefaultVascEntry.class);
} else if ("field".equals(vascType)) {
return new BeanVascEntryRecordCreator(DefaultVascEntryField.class);
} else if ("fieldset".equals(vascType)) {
return new BeanVascEntryRecordCreator(DefaultVascEntryFieldSet.class);
} else if ("linkentries".equals(vascType)) {
return new BeanVascEntryRecordCreator(DefaultVascEntryLink.class);
} else if ("listoptions".equals(vascType)) {
return new BeanVascEntryRecordCreator(DefaultVascEntryField.class);
}
return null;
}
/**
* @return the vascController
*/
public VascController getVascController() {
return vascController;
}
/**
* @param vascController the vascController to set
*/
public void setVascController(VascController vascController) {
this.vascController = vascController;
}
/**
* @return the vascType
*/
public String getVascType() {
return vascType;
}
/**
* @param vascType the vascType to set
*/
public void setVascType(String vascType) {
this.vascType = vascType;
}
}

View file

@ -0,0 +1,8 @@
/**
*
*/
/**
* @author willemc
*
*/
package net.forwardfire.vasc.opt.editor;

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<modules version="1.0"
xmlns="http://language.x4o.org/xml/ns/modules"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://language.x4o.org/xml/ns/modules http://language.x4o.org/xml/ns/modules-1.0.xsd"
>
<language version="1.0">
<eld-resource>vasc-opt-editor.eld</eld-resource>
</language>
</modules>

View file

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<root:module
xmlns="http://eld.x4o.org/xml/ns/eld-lang"
xmlns:root="http://eld.x4o.org/xml/ns/eld-root"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://eld.x4o.org/xml/ns/eld-root http://eld.x4o.org/xml/ns/eld-root-1.0.xsd"
providerHost="vasc.forwardfire.net"
providerName="Vasc Opt Editor"
id="vasc-opt-editor"
>
<description>Provides Vasc entry editing entries.</description>
<namespace uri="http://vasc.forwardfire.net/xml/ns/vasc-opt-editor"
schemaUri="http://vasc.forwardfire.net/xml/ns/vasc-opt-editor-1.0.xsd"
schemaResource="vasc-opt-editor-1.0.xsd"
schemaPrefix="oe"
name="Vasc Opt Editor"
id="ns-vasc-opt-oe"
>
<description>Provides vasc entie editing support.</description>
<element tag="virtualVascBackend" objectClass="net.forwardfire.vasc.opt.editor.VirtualVascBackend">
<configurator id="virtualVascBackend-VascBackendElementConfigurator" bean.class="net.forwardfire.vasc.impl.x4o.VascBackendElementConfigurator" configAction="true"/>
<elementParent tag="root" uri="http://vasc.forwardfire.net/xml/ns/vasc-root"/>
</element>
</namespace>
</root:module>

View file

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="UTF-8"?>
<tree:root
xmlns:tree="http://vasc.forwardfire.net/xml/ns/vasc-root"
xmlns:v="http://vasc.forwardfire.net/xml/ns/vasc-lang"
xmlns:oe="http://vasc.forwardfire.net/xml/ns/vasc-opt-editor"
>
<oe:virtualVascBackend id="VascEntryBackend" vascController="${vascController}" vascType="entry"/>
<v:entry id="VascEntry" backendId="VascEntryBackend">
<v:field id="id"/>
<v:field id="backendId" list="false"/>
<v:field id="name" list="false"/>
<v:field id="helpId" list="false"/>
<v:field id="image" list="false"/>
<v:field id="listDescription" list="false"/>
<v:field id="listImage" list="false"/>
<v:field id="editDescription" list="false"/>
<v:field id="editImage" list="false"/>
<v:field id="deleteDescription" list="false"/>
<v:field id="deleteImage" list="false"/>
<v:field id="createDescription" list="false"/>
<v:field id="createImage" list="false"/>
<v:field id="primaryKeyFieldId" list="false"/>
<v:field id="displayNameFieldId" list="false"/>
<v:field id="vascDisplayOnly" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="vascAdminList" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="vascAdminEdit" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="vascAdminCreate" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="vascAdminDelete" list="false" vascEntryFieldType="BooleanField"/>
<v:link id="VascEntryField" vascEntryId="VascEntryFieldLink">
<v:linkCreateFieldValue valueFieldId="vascEntry"/>
<v:linkParameter name="entry_id" valueFieldId="id"/>
</v:link>
<v:link id="VascEntryFieldSet" vascEntryId="VascEntryFieldSetLink">
<v:linkParameter name="entry_id" valueFieldId="id"/>
</v:link>
<v:link id="VascLinkEntry" vascEntryId="VascLinkEntryLink">
<v:linkCreateFieldValue valueFieldId="vascEntry"/>
<v:linkParameter name="entry_id" valueFieldId="id"/>
</v:link>
<v:link id="VascListOption" vascEntryId="VascListOptionLink">
<v:linkCreateFieldValue valueFieldId="vascEntry"/>
<v:linkParameter name="entry_id" valueFieldId="id"/>
</v:link>
</v:entry>
<oe:virtualVascBackend id="VascEntryFieldLinkBackend" vascController="${vascController}" vascType="field" />
<v:entry id="VascEntryFieldLink" backendId="VascEntryFieldLinkBackend">
<v:field id="id"/>
<v:field id="backendName" list="false"/>
<v:field id="displayName" list="false"/>
<v:field id="vascEntryFieldType" list="false" editReadOnly="true"/>
<v:field id="vascEntryFieldValue" list="false" editReadOnly="true"/>
<v:field id="name"/>
<v:field id="description" list="false"/>
<v:field id="helpId" list="false"/>
<v:field id="image" list="false"/>
<v:field id="order" vascEntryFieldType="IntegerField"/>
<v:field id="defaultValue"/>
<v:field id="sizeList" list="false" vascEntryFieldType="IntegerField"/>
<v:field id="sizeEdit" list="false" vascEntryFieldType="IntegerField"/>
<v:field id="styleList" list="false"/>
<v:field id="styleEdit" list="false"/>
<v:field id="choices" list="false"/>
<v:field id="choicesAsRadio" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="view" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="optional" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="create" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="edit" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="editReadOnly" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="editBlank" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="list" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="rolesCreate" list="false"/>
<v:field id="rolesEdit" list="false"/>
<v:field id="rolesEditReadOnly" list="false"/>
<v:field id="rolesList" list="false"/>
<v:field id="sortable" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="sumable" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="graphable" list="false" vascEntryFieldType="BooleanField"/>
<!-- private List<VascValidator> vascValidators = null; -->
</v:entry>
<oe:virtualVascBackend id="VascEntryFieldSetLinkBackend" vascController="${vascController}" vascType="fieldset" />
<v:entry id="VascEntryFieldSetLink" backendId="VascEntryFieldSetLinkBackend">
<v:field id="id"/>
<v:field id="name"/>
<v:field id="description" list="false"/>
<v:field id="helpId" list="false"/>
<v:field id="image" list="false"/>
<v:field id="styleList" list="false"/>
<v:field id="styleEdit" list="false"/>
<v:field id="collapsed" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="optional" list="false" vascEntryFieldType="BooleanField"/>
<!-- private List<String> vascEntryFieldIds = null; -->
</v:entry>
<oe:virtualVascBackend id="VascLinkEntryLinkBackend" vascController="${vascController}" vascType="linkentries" />
<v:entry id="VascLinkEntryLink" backendId="VascLinkEntryLinkBackend">
<v:field id="id"/>
<v:field id="vascEntryId"/>
<v:field id="vascEntryLinkType" list="false" vascEntryFieldType="ListField">
<v:vascSelectItemModelEnum enumClass="net.forwardfire.vasc.core.VascEntryLinkType"/>
</v:field>
<v:field id="doActionId" list="false"/>
<v:field id="name" list="false"/>
<!--
private Map<String,String> entryParameterFieldIds = new HashMap<String,String>(3);
private Map<String,String> entryCreateFieldValues = new HashMap<String,String>(3);
-->
</v:entry>
<oe:virtualVascBackend id="VascListOptionLinkBackend" vascController="${vascController}" vascType="listoptions" />
<v:entry id="VascListOptionLink" backendId="VascListOptionLinkBackend">
<v:field id="id"/>
<v:field id="name"/>
<v:field id="description" list="false"/>
<v:field id="helpId" list="false"/>
<v:field id="image" list="false"/>
<v:field id="styleList" list="false"/>
<v:field id="styleEdit" list="false"/>
<v:field id="collapsed" list="false" vascEntryFieldType="BooleanField"/>
<v:field id="optional" list="false" vascEntryFieldType="BooleanField"/>
<!-- private List<String> vascEntryFieldIds = null; -->
</v:entry>
</tree:root>