use of org.collectionspace.chain.csp.config.RuleTarget in project application by collectionspace.
the class WebUI method configure.
@Override
public void configure(RuleSet rules) throws CSPDependencyException {
/* MAIN/ui/web -> UI */
rules.addRule(SECTIONED, new String[] { "ui", "web" }, SECTION_PREFIX + "web", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
((CoreConfig) parent).setRoot(WEBUI_ROOT, WebUI.this);
if (section.getValue("/tmp-schema-path") != null) {
// XXX
uispec_path = System.getProperty("java.io.tmpdir") + "/ju-cspace";
// fix
} else {
uispec_path = (String) section.getValue("/schema-path");
}
login_dest = (String) section.getValue("/login-dest");
login_failed_dest = (String) section.getValue("/login-failed-dest");
front_page = (String) section.getValue("/front-page");
find_page = (String) section.getValue("/find-page");
return WebUI.this;
}
});
/* MAIN/ui/web/mappings ->UI */
rules.addRule(SECTION_PREFIX + "web", new String[] { "mappings", "map" }, SECTION_PREFIX + "uimapping", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
uiMapping = new UIMapping((WebUI) parent, section);
addMapping(uiMapping);
return uiMapping;
}
});
rules.addRule(SECTION_PREFIX + "uimapping", new String[] { "configure", "meta" }, SECTION_PREFIX + "uimetamapping", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
UIMapping map = (UIMapping) parent;
uiMeta = new UIMeta((UIMapping) parent, section);
map.addMetaConfig(uiMeta);
return uiMeta;
}
});
}
use of org.collectionspace.chain.csp.config.RuleTarget in project application by collectionspace.
the class Spec method configure.
@Override
public void configure(RuleSet rules) {
/* MAIN/tenantid -> string */
rules.addRule(SECTIONED, new String[] { "tenantid" }, SECTION_PREFIX + "tenantid", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
tenantid = (String) section.getValue("");
tenantname = (String) section.getParent().getValue("/@tenantname");
return this;
}
});
/* MAIN/version -> string */
rules.addRule(SECTIONED, new String[] { "version" }, SECTION_PREFIX + "version", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
version = (String) section.getValue("");
return this;
}
});
/* MAIN/email -> EmailData */
rules.addRule(SECTIONED, new String[] { "email" }, SECTION_PREFIX + "email", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
ed = new EmailData(Spec.this, section);
return this;
}
});
/* MAIN/admin -> AdminData */
rules.addRule(SECTIONED, new String[] { "admin" }, SECTION_PREFIX + "admin", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
adminData = new AdminData(Spec.this, section);
return this;
}
});
/* MAIN/spec -> SPEC */
rules.addRule(SECTIONED, new String[] { "spec" }, SECTION_PREFIX + "spec", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
((CoreConfig) parent).setRoot(SPEC_ROOT, Spec.this);
return Spec.this;
}
});
/* SPEC/schemas -> SCHEMAS */
rules.addRule(SECTION_PREFIX + "spec", new String[] { "schemas" }, SECTION_PREFIX + "schemas", null, null);
/* RELATIONSHIPS/relation -> RELATION(@id) */
rules.addRule(SECTION_PREFIX + "schemas", new String[] { "schema" }, SECTION_PREFIX + "schema", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Schemas s = new Schemas(Spec.this, section);
schemas.put(s.getID(), s);
return s;
}
});
/* SPEC/relationships -> RELATIONSHIPS */
rules.addRule(SECTION_PREFIX + "spec", new String[] { "relationships" }, SECTION_PREFIX + "relationships", null, null);
/* RELATIONSHIPS/relation -> RELATION(@id) */
rules.addRule(SECTION_PREFIX + "relationships", new String[] { "relation" }, SECTION_PREFIX + "relation", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Relationship r = new Relationship(Spec.this, section);
relationships.put(r.getID(), r);
relationshipsPredicate.put(r.getPredicate(), r);
if (r.hasInverse()) {
inverserelationships.put(r.getInverse(), r.getID());
}
return r;
}
});
/* SPEC/records -> RECORDS */
rules.addRule(SECTION_PREFIX + "spec", new String[] { "records" }, SECTION_PREFIX + "records", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Map<String, String> recordsdata = new HashMap<String, String>();
String blanks = "";
blanks = (String) section.getValue("/enum-blank");
if (blanks == null) {
blanks = "Default String";
}
recordsdata.put("blank", blanks);
return recordsdata;
}
});
/* RECORDS/record -> RECORD(@id) */
rules.addRule(SECTION_PREFIX + "records", new String[] { "record" }, SECTION_PREFIX + "record", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Map<String, String> data = (Map<String, String>) parent;
Record r = new Record(Spec.this, section, data);
records.put(r.getID(), r);
records_by_web_url.put(r.getWebURL(), r);
records_by_services_url.put(r.getServicesURL(), r);
records_by_services_docType.put(r.getServicesTenantSg(), r);
return r;
}
});
/* SPEC/section -> Sections */
rules.addRule(SECTION_PREFIX + "record", new String[] { "section" }, SECTION_PREFIX + "uisection", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
String id = (String) section.getValue("/@id");
Record r = (Record) parent;
r.addUISection("base", id);
return r;
}
});
/* Section/section -> Sections */
rules.addRule(SECTION_PREFIX + "uisection", new String[] { "section" }, SECTION_PREFIX + "uisection", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
String id = (String) section.getValue("/@id");
Record r = (Record) parent;
r.addUISection("base", id);
return r;
}
});
/* RECORD/services-instances-path -> RECORDPATH */
rules.addRule(SECTION_PREFIX + "record", new String[] { "services-single-instance-path" }, SECTION_PREFIX + "instance-path", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Record r = (Record) parent;
String id = (String) section.getValue("/@id");
if (id == null)
id = "common";
r.setServicesInstancePath(id, (String) section.getValue(""));
return r;
}
});
/* RECORD/services-record-path -> RECORDPATH */
rules.addRule(SECTION_PREFIX + "record", new String[] { "services-record-path" }, SECTION_PREFIX + "record-path", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Record r = (Record) parent;
String id = (String) section.getValue("/@id");
if (id == null)
id = "common";
r.setServicesRecordPath(id, (String) section.getValue(""));
return r;
}
});
/* RECORD/instances/instance -> INSTANCE */
rules.addRule(SECTION_PREFIX + "record", new String[] { "instances", "instance" }, SECTION_PREFIX + "instance", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Instance n = new Instance((Record) parent, section);
((Record) parent).addInstance(n);
return n;
}
});
/* FIELD/options/option -> OPTION */
rules.addRule(SECTION_PREFIX + "instance", new String[] { "options", "option" }, SECTION_PREFIX + "option", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Instance n = (Instance) parent;
boolean dfault = false;
String value = (String) section.getValue("/@default");
dfault = (value != null && ("yes".equals(value.toLowerCase()) || "1".equals(value.toLowerCase())));
n.addOption((String) section.getValue("/@id"), (String) section.getValue(""), (String) section.getValue("/@sample"), dfault, (String) section.getValue("/@desc"));
return n;
}
});
/* RECORD/field -> FIELD */
rules.addRule(SECTION_PREFIX + "uisection", new String[] { "field" }, SECTION_PREFIX + "field", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Field f = new Field((Record) parent, section);
((Record) parent).addField(f);
String is_chooser = (String) section.getValue("/@chooser");
if (is_chooser != null && ("1".equals(is_chooser) || "yes".equals(is_chooser.toLowerCase())))
f.setType("chooser");
return f;
}
});
/* RECORD/structures/structure -> STRUCTURE */
rules.addRule(SECTION_PREFIX + "record", new String[] { "structures", "structure" }, SECTION_PREFIX + "structure", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Structure s = new Structure((Record) parent, section);
((Record) parent).addStructure(s);
return s;
}
});
/* STRUCTURE/repeat -> REPEAT */
rules.addRule(SECTION_PREFIX + "structure", new String[] { "view", "sidebar", "repeat" }, SECTION_PREFIX + "repeat", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Repeat r = new Repeat((Structure) parent, section);
((Structure) parent).addSideBar(r);
return r;
}
});
//
/* FIELD/options/option -> OPTION */
rules.addRule(SECTION_PREFIX + "structure", new String[] { "view", "hierarchy-section", "options", "option" }, SECTION_PREFIX + "option", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Structure n = (Structure) parent;
boolean dfault = false;
String value = (String) section.getValue("/@default");
dfault = (value != null && ("yes".equals(value.toLowerCase()) || "1".equals(value.toLowerCase())));
n.addOption((String) section.getValue("/@id"), (String) section.getValue(""), (String) section.getValue("/@sample"), dfault);
return n;
}
});
/* STRUCTURE/repeat -> REPEAT */
rules.addRule(SECTION_PREFIX + "structure", new String[] { "repeat" }, SECTION_PREFIX + "repeat", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Repeat r = new Repeat((Structure) parent, section);
((Structure) parent).addField(r);
((Structure) parent).addAllField(r);
return r;
}
});
/* RECORD/repeat -> REPEAT */
rules.addRule(SECTION_PREFIX + "uisection", new String[] { "repeat" }, SECTION_PREFIX + "repeat", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Repeat r = new Repeat((Record) parent, section);
((Record) parent).addField(r);
return r;
}
});
/* REPEAT/field -> FIELD */
rules.addRule(SECTION_PREFIX + "repeat", new String[] { "field" }, SECTION_PREFIX + "field", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Field f = new Field((Repeat) parent, section);
f.getRecord().addField(f);
((Repeat) parent).addChild(f);
return f;
}
});
/* RECORD/group -> GROUP */
rules.addRule(SECTION_PREFIX + "uisection", new String[] { "group" }, SECTION_PREFIX + "group", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Group r = new Group((Record) parent, section);
((Record) parent).addField(r);
return r;
}
});
/* GROUP/field -> FIELD */
rules.addRule(SECTION_PREFIX + "group", new String[] { "field" }, SECTION_PREFIX + "field", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Field f = new Field((Group) parent, section);
f.getRecord().addField(f);
((Group) parent).addChild(f);
return f;
}
});
/* GROUP/group -> GROUP */
rules.addRule(SECTION_PREFIX + "group", new String[] { "group" }, SECTION_PREFIX + "group", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Group r = new Group((Group) parent, section);
((Group) parent).addChild(r);
r.getRecord().addField(r);
return r;
}
});
/* REPEAT/group -> GROUP */
rules.addRule(SECTION_PREFIX + "repeat", new String[] { "group" }, SECTION_PREFIX + "group", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Group r = new Group((Repeat) parent, section);
((Repeat) parent).addChild(r);
r.getRecord().addField(r);
return r;
}
});
/* GROUP/repeat -> REPEAT */
rules.addRule(SECTION_PREFIX + "group", new String[] { "repeat" }, SECTION_PREFIX + "repeat", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Repeat r = new Repeat((Repeat) parent, section);
((Group) parent).addChild(r);
r.getRecord().addField(r);
return r;
}
});
/* REPEAT/repeat -> REPEAT */
rules.addRule(SECTION_PREFIX + "repeat", new String[] { "repeat" }, SECTION_PREFIX + "repeat", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Repeat r = new Repeat((Repeat) parent, section);
((Repeat) parent).addChild(r);
r.getRecord().addField(r);
return r;
}
});
/* FIELD/options/option -> OPTION */
rules.addRule(SECTION_PREFIX + "field", new String[] { "options", "option" }, SECTION_PREFIX + "option", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Field f = (Field) parent;
boolean dfault = false;
String value = (String) section.getValue("/@default");
dfault = (value != null && ("yes".equals(value.toLowerCase()) || "1".equals(value.toLowerCase())));
f.addOption((String) section.getValue("/@id"), (String) section.getValue(""), (String) section.getValue("/@sample"), dfault);
return f;
}
});
/* FIELD/merges/merge -> OPTION */
rules.addRule(SECTION_PREFIX + "field", new String[] { "merges", "merge" }, SECTION_PREFIX + "merge", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
Field f = (Field) parent;
f.addMerge((String) section.getValue("/@id"), (String) section.getValue("/@rank"));
/*
boolean dfault=false;
String value=(String)section.getValue("/@default");
dfault=(value!=null && ("yes".equals(value.toLowerCase()) || "1".equals(value.toLowerCase())));
f.addOption((String)section.getValue("/@id"),(String)section.getValue(""),(String)section.getValue("/@sample"),dfault);
*/
return f;
}
});
}
use of org.collectionspace.chain.csp.config.RuleTarget in project application by collectionspace.
the class ServicesStorageGenerator method configure.
@Override
public void configure(RuleSet rules) throws CSPDependencyException {
/* MAIN/persistence/service -> SERVICE */
rules.addRule(SECTIONED, new String[] { "persistence", "service" }, SECTION_PREFIX + "service", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection milestone) {
((ConfigRoot) parent).setRoot(SERVICE_ROOT, ServicesStorageGenerator.this);
base_url = (String) milestone.getValue("/url");
// XXX should be path-selectable
((ConfigRoot) parent).setRoot(CSPContext.XXX_SERVICE_NAME, "service");
ims_url = (String) milestone.getValue("/ims-url");
tenantSpec = new TenantSpec(milestone);
return ServicesStorageGenerator.this;
}
});
rules.addRule(SECTION_PREFIX + "service", new String[] { "remoteclients", "remoteclient" }, SECTION_PREFIX + "remoteclient", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection milestone) throws Exception {
String name = (String) milestone.getValue("/name");
String url = (String) milestone.getValue("/url");
String username = (String) milestone.getValue("/user");
String password = (String) milestone.getValue("/password");
String sslString = (String) milestone.getValue("/ssl");
boolean ssl = false;
if (sslString != null && sslString.equalsIgnoreCase(Boolean.toString(true))) {
ssl = true;
}
String authString = (String) milestone.getValue("/auth");
boolean auth = false;
if (authString != null && authString.equalsIgnoreCase(Boolean.toString(true))) {
auth = true;
}
String tenantId = (String) milestone.getValue("/tenantId");
String tenantName = (String) milestone.getValue("/tenantName");
RemoteClient remoteClient = tenantSpec.new RemoteClient(name, url, username, password, ssl, auth, tenantId, tenantName);
tenantSpec.addRemoteClient(remoteClient);
return this;
}
});
rules.addRule(SECTION_PREFIX + "service", new String[] { "repository", "dateformats", "pattern" }, SECTION_PREFIX + "dateformat", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection milestone) {
String format = (String) milestone.getValue("");
tenantSpec.addFormat(format);
return this;
}
});
rules.addRule(SECTION_PREFIX + "service", new String[] { "repository", "languages", "language" }, SECTION_PREFIX + "language", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection milestone) {
String lang = (String) milestone.getValue("");
tenantSpec.addLanguage(lang);
return this;
}
});
}
use of org.collectionspace.chain.csp.config.RuleTarget in project application by collectionspace.
the class CoreConfig method configure.
@Override
public void configure(RuleSet rules) {
rules.addRule("ROOT", new String[] { "collection-space" }, "org.collectionspace.app.cfg.main", null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection milestone) {
return this;
}
});
rules.addRule("org.collectionspace.app.cfg.main", new String[] { "cspace-config" }, SECTIONED, null, new RuleTarget() {
@Override
public Object populate(Object parent, ReadOnlySection section) {
return CoreConfig.this;
}
});
/* ROOT/collection-space -> MAIN */
}
Aggregations