use of org.apache.ofbiz.entity.model.ModelViewEntity.ModelViewLink in project ofbiz-framework by apache.
the class DynamicViewEntity method getViewElement.
public Element getViewElement(Document doc, String entityName) {
Element viewElement = doc.createElement("view-entity");
viewElement.setAttribute("entity-name", entityName);
for (ModelMemberEntity member : memberModelMemberEntities.values()) {
Element memberElement = doc.createElement("member-entity");
memberElement.setAttribute("entity-alias", member.getEntityAlias());
memberElement.setAttribute("entity-name", member.getEntityName());
viewElement.appendChild(memberElement);
}
for (ModelAliasAll aliasAll : aliasAlls) {
Element aliasAllElement = doc.createElement("alias-all");
aliasAllElement.setAttribute("entity-alias", aliasAll.getEntityAlias());
if (UtilValidate.isNotEmpty(aliasAll.getPrefix()))
aliasAllElement.setAttribute("prefix", aliasAll.getPrefix());
if (aliasAll.getGroupBy())
aliasAllElement.setAttribute("group-by", "true");
if (UtilValidate.isNotEmpty(aliasAll.getFunction()))
aliasAllElement.setAttribute("function", aliasAll.getFunction());
for (String excludeField : aliasAll) {
Element excludeElement = doc.createElement("exclude");
excludeElement.setAttribute("field", excludeField);
aliasAllElement.appendChild(excludeElement);
}
viewElement.appendChild(aliasAllElement);
}
for (ModelAlias alias : aliases) {
Element aliasElement = doc.createElement("alias");
aliasElement.setAttribute("entity-alias", alias.getEntityAlias());
aliasElement.setAttribute("name", alias.getName());
if (!alias.getName().equals(alias.getField()))
aliasElement.setAttribute("field", alias.getField());
String colAlias = ModelUtil.dbNameToVarName(alias.getColAlias());
if (!alias.getName().equals(colAlias))
aliasElement.setAttribute("col-alias", colAlias);
if (alias.getIsPk() != null)
aliasElement.setAttribute("prim-key", alias.getIsPk().toString());
if (alias.getGroupBy())
aliasElement.setAttribute("group-by", "true");
if (UtilValidate.isNotEmpty(alias.getFunction()))
aliasElement.setAttribute("function", alias.getFunction());
// TODO: description, complex-alias
viewElement.appendChild(aliasElement);
}
for (ModelViewLink viewLink : viewLinks) {
Element viewLinkElement = doc.createElement("view-link");
viewLinkElement.setAttribute("entity-alias", viewLink.getEntityAlias());
if (viewLink.isRelOptional())
viewLinkElement.setAttribute("rel-optional", "true");
viewLinkElement.setAttribute("rel-entity-alias", viewLink.getRelEntityAlias());
for (ModelKeyMap keyMap : viewLink) {
Element keyMapElement = doc.createElement("key-map");
keyMapElement.setAttribute("field-name", keyMap.getFieldName());
if (!keyMap.getFieldName().equals(keyMap.getRelFieldName()))
keyMapElement.setAttribute("rel-field-name", keyMap.getRelFieldName());
viewLinkElement.appendChild(keyMapElement);
}
// TODO: conditions
viewElement.appendChild(viewLinkElement);
}
for (ModelRelation relation : relations) {
viewElement.appendChild(relation.toXmlElement(doc));
}
return viewElement;
}
use of org.apache.ofbiz.entity.model.ModelViewEntity.ModelViewLink in project ofbiz-framework by apache.
the class DynamicViewEntity method addViewLink.
public void addViewLink(String entityAlias, String relEntityAlias, Boolean relOptional, List<ModelKeyMap> modelKeyMaps) {
ModelViewLink modelViewLink = new ModelViewLink(entityAlias, relEntityAlias, relOptional, null, modelKeyMaps);
this.viewLinks.add(modelViewLink);
}
Aggregations