use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class FormPropertyType method toRhinoValue.
@Override
public Object toRhinoValue(Object webComponentValue, PropertyDescription pd, IWebObjectContext webObjectContext, Scriptable startScriptable) {
if (webComponentValue instanceof Form) {
return ((Form) webComponentValue).getName();
} else {
if (webComponentValue != null && webObjectContext != null && webObjectContext.getUnderlyingWebObject() instanceof IContextProvider) {
// form is stored as uuid on disk
FlattenedSolution solution = ((IContextProvider) webObjectContext.getUnderlyingWebObject()).getDataConverterContext().getSolution();
Form form = solution.getForm(webComponentValue.toString());
if (form == null) {
form = (Form) solution.searchPersist(webComponentValue.toString());
}
if (form != null) {
return form.getName();
}
}
}
return webComponentValue;
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class FormTemplateGenerator method isSingleValueComponent.
/**
* @return false if the persist has no valuelist or at most one value in the valuelist, true otherwise
*/
public static boolean isSingleValueComponent(IFormElement persist) {
Field field = (Field) persist;
if (field.getValuelistID() > 0) {
try {
IApplicationServer as = ApplicationServerRegistry.getService(IApplicationServer.class);
FlattenedSolution fs = new FlattenedSolution((SolutionMetaData) ApplicationServerRegistry.get().getLocalRepository().getRootObjectMetaData(((Solution) persist.getRootObject()).getName(), IRepository.SOLUTIONS), new AbstractActiveSolutionHandler(as) {
@Override
public IRepository getRepository() {
return ApplicationServerRegistry.get().getLocalRepository();
}
});
ValueList valuelist = fs.getValueList(field.getValuelistID());
return isSingleValue(valuelist);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return true;
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class FindState method getRelatedFoundSet.
/*
* _____________________________________________________________ Related states implementation
*/
/**
* Get related foundset, relationName may be multiple-levels deep
*/
public IFoundSetInternal getRelatedFoundSet(String relationName, List<SortColumn> defaultSortColumns) {
if (relationName == null || parent == null)
return null;
String partName = relationName;
String restName = null;
int index = relationName.indexOf('.');
if (index > 0) {
partName = relationName.substring(0, index);
restName = relationName.substring(index + 1);
}
IFoundSetInternal rfs = relatedStates.get(partName);
if (rfs == null) {
FlattenedSolution fs = parent.getFoundSetManager().getApplication().getFlattenedSolution();
Relation r = fs.getRelation(partName);
// safety
if (r == null)
return null;
try {
if (r.isGlobal() || r.isParentRef()) {
rfs = parent.getRelatedFoundSet(this, partName, defaultSortColumns);
// do not store in relatedStates because it is not a relatedfindfoundset
} else {
if (!getValidSearchRelations().contains(r)) {
if (relatedFoundsetErrorReported == null)
relatedFoundsetErrorReported = new ArrayList<>();
if (!relatedFoundsetErrorReported.contains(partName)) {
relatedFoundsetErrorReported.add(partName);
String reason = "";
if (r.isGlobal())
reason = "global relation";
else if (r.isMultiServer())
reason = "multi server";
else if (!Relation.isValid(r, fs))
reason = "server/table not valid/loaded";
else {
reason = "relation primary datasource: " + r.getPrimaryDataSource() + " != findstate primary datasource: " + parent.getDataSource();
}
Debug.warn("Find: skip related search for '" + partName + "', relation cannot be used in search, because: " + reason);
parent.getFoundSetManager().getApplication().reportJSWarning(Messages.getString("servoy.relation.find.unusable", new Object[] { partName }) + " (" + reason + ')', // $NON-NLS-2$
null);
}
return null;
}
SQLSheet sheet = parent.getSQLSheet().getRelatedSheet(((FoundSetManager) parent.getFoundSetManager()).getApplication().getFlattenedSolution().getRelation(partName), ((FoundSetManager) parent.getFoundSetManager()).getSQLGenerator());
rfs = ((FoundSetManager) parent.getFoundSetManager()).createRelatedFindFoundSet(this, partName, sheet);
((FoundSet) rfs).addParent(this);
((FoundSet) rfs).setFindMode();
relatedStates.put(partName, rfs);
}
} catch (ServoyException ex) {
// $NON-NLS-1$
Debug.error("Error making related findstate", ex);
return null;
}
}
if (restName != null) {
IRecordInternal record = rfs.getRecord(rfs.getSelectedIndex());
if (record == null)
return null;
return record.getRelatedFoundSet(restName);
}
return rfs;
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class DataProviderEditor method fillDataProviderList.
protected void fillDataProviderList() {
try {
ITable table = null;
if (definedTable == null) {
FormManager fm = (FormManager) application.getFormManager();
FormController fc = fm.getCurrentMainShowingFormController();
if (fc != null) {
Form form = fc.getForm();
table = application.getFlattenedSolution().getTable(form.getDataSource());
}
} else {
if (!showRelatedOptionsOnly)
table = definedTable;
}
DefaultListModel model = (DefaultListModel) list.getModel();
model.removeAllElements();
if (showNoneOption)
model.addElement("-none-");
if (!showColumnsOnly)
model.addElement("*columns");
Object o = relationsComboBox.getSelectedItem();
if (o != null) {
if (o instanceof String) {
// table = form.getTable();
} else {
table = application.getFlattenedSolution().getTable(((Relation) o).getForeignDataSource());
}
if (table != null) {
Iterator<Column> it = table.getColumnsSortedByName();
while (it.hasNext()) {
IColumn c = it.next();
ColumnInfo ci = c.getColumnInfo();
if (ci != null && ci.isExcluded()) {
continue;
}
if (hideMediaColumns) {
// use dataprovider type as defined by column converter
ComponentFormat componentFormat = ComponentFormat.getComponentFormat(null, c, application);
if (componentFormat.dpType == IColumnTypes.MEDIA) {
continue;
}
}
model.addElement(c);
}
}
}
FlattenedSolution s = application.getFlattenedSolution();
if (table != null && !showColumnsOnly) {
Iterator it = s.getScriptCalculations(table, true);
if (it.hasNext()) {
model.addElement("*calculations");
}
while (it.hasNext()) {
ScriptCalculation sc = (ScriptCalculation) it.next();
for (int i = 0; i < model.size(); i++) {
Object obj = model.elementAt(i);
if (obj instanceof IDataProvider) {
IDataProvider dp = (IDataProvider) obj;
if (dp.getDataProviderID().equals(sc.getDataProviderID())) {
// remove the column from the list if use by
model.remove(i);
// stored calc
break;
}
}
}
model.addElement(sc);
}
Iterator it2 = s.getScriptVariables(true);
if (it2.hasNext()) {
model.addElement("*globals");
}
while (it2.hasNext()) {
model.addElement(it2.next());
}
Iterator it3 = s.getAggregateVariables(table, true);
if (it3.hasNext()) {
model.addElement("*aggregates");
}
while (it3.hasNext()) {
model.addElement(it3.next());
}
}
if (table != null && showColumnsOnly && showSortableOnly) {
Iterator it3 = s.getAggregateVariables(table, true);
while (it3.hasNext()) {
model.addElement(it3.next());
}
}
if (showGlobalsOption && showColumnsOnly) {
Iterator it2 = s.getScriptVariables(true);
if (it2.hasNext()) {
model.addElement("*globals");
}
while (it2.hasNext()) {
model.addElement(it2.next());
}
}
} catch (Exception ex) {
Debug.error(ex);
}
}
use of com.servoy.j2db.FlattenedSolution in project servoy-client by Servoy.
the class FormElementHelper method reload.
public void reload() {
persistWrappers.clear();
formTabSequences.clear();
formComponentElements.clear();
formComponentElementsForDesign.clear();
FormComponentCache.templateCache.clear();
for (FlattenedSolution fs : globalFlattendSolutions.values()) {
fs.close(null);
}
globalFlattendSolutions.clear();
}
Aggregations