use of com.servoy.j2db.persistence.Solution in project servoy-client by Servoy.
the class SelectNGSolutionFilter method doFilter.
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
if (Utils.getAsBoolean(Settings.getInstance().getProperty("servoy.allowSolutionBrowsing", "true"))) {
HttpServletRequest request = (HttpServletRequest) servletRequest;
String uri = request.getServletPath();
if (uri != null) {
if (uri.equals("/servoy-ngclient")) {
// html contents
((HttpServletResponse) servletResponse).setContentType("text/html");
PrintWriter w = servletResponse.getWriter();
addNeededJSAndCSS(getClass().getResource("solution_list.html"), w);
w.flush();
return;
} else if (uri.equals("/servoy-ngclient/solutions.js")) {
HTTPUtils.setNoCacheHeaders((HttpServletResponse) servletResponse);
IApplicationServerSingleton as = ApplicationServerRegistry.get();
// js contents giving the actual solutions list
List<Solution> ngCompatibleSolutions = new ArrayList<Solution>();
if (as.isDeveloperStartup()) {
Solution active = as.getDebugClientHandler().getDebugSmartClient().getCurrent();
if ((((SolutionMetaData) active.getMetaData()).getSolutionType() & (SolutionMetaData.SOLUTION | SolutionMetaData.NG_CLIENT_ONLY)) != 0)
ngCompatibleSolutions.add(active);
} else {
try {
RootObjectMetaData[] smds = as.getLocalRepository().getRootObjectMetaDatasForType(IRepository.SOLUTIONS);
int solutionType;
for (RootObjectMetaData element : smds) {
solutionType = ((SolutionMetaData) element).getSolutionType();
if ((solutionType & (SolutionMetaData.SOLUTION | SolutionMetaData.NG_CLIENT_ONLY)) > 0) {
Solution solution = (Solution) as.getLocalRepository().getActiveRootObject(element.getRootObjectId());
if (solution != null) {
ngCompatibleSolutions.add(solution);
}
}
}
} catch (RepositoryException e) {
Debug.error(e);
}
}
// now generate the js containing these solutions
((HttpServletResponse) servletResponse).setContentType("text/javascript");
PrintWriter w = servletResponse.getWriter();
w.println("angular.module('solutionsListModule', []).value('$solutionsList', {");
w.println(" ngSolutions: [");
boolean putComma = false;
for (Solution s : ngCompatibleSolutions) {
if (putComma)
w.println(",");
else
putComma = true;
String titleText = (s.getTitleText() != null ? "'" + s.getTitleText() + "'" : null);
// it wouldn't look nice in the list of solutions to pick + client can't convert those
if (titleText != null && (titleText.contains("#") || titleText.startsWith("i18n:")))
titleText = null;
w.print(" { name : '" + s.getName() + "', titleText : " + titleText + ", requiresAuth : " + s.requireAuthentication() + " }");
}
if (putComma)
w.println("");
w.println(" ]");
w.println("});");
w.flush();
return;
}
}
}
filterChain.doFilter(servletRequest, servletResponse);
}
use of com.servoy.j2db.persistence.Solution in project servoy-client by Servoy.
the class FormElementHelper method getFormComponentCache.
public FormComponentCache getFormComponentCache(INGFormElement formElement, PropertyDescription pd, JSONObject formElementValue, Form form, FlattenedSolution fs) {
ConcurrentMap<UUID, Map<String, FormComponentCache>> cache = formElement.getDesignId() != null ? formComponentElementsForDesign : formComponentElements;
Solution solutionCopy = fs.getSolutionCopy(false);
FlattenedSolution usedFS = getSharedFlattenedSolution(fs);
if (solutionCopy != null && solutionCopy.getForm(formElement.getForm().getName()) != null) {
usedFS = fs;
// if the form is a solution model for we can't use the standard caches.
cache = solutionCopy.getRuntimeProperty(SOLUTION_MODEL_CACHE);
if (cache == null) {
cache = new ConcurrentHashMap<UUID, Map<String, FormComponentCache>>();
solutionCopy.setRuntimeProperty(SOLUTION_MODEL_CACHE, cache);
}
}
return getFormComponentFromCache(formElement, pd, formElementValue, form, usedFS, cache);
}
use of com.servoy.j2db.persistence.Solution in project servoy-client by Servoy.
the class EditRecordList method stopEditing.
/**
* stop/save
*
* @param javascriptStop
* @param recordsToSave null means all records
* @return IRowChangeListener static final
*/
@SuppressWarnings("nls")
public int stopEditing(boolean javascriptStop, List<IRecord> recordsToSave) {
int stopped = stopEditingImpl(javascriptStop, recordsToSave, 0);
if ((stopped == ISaveConstants.VALIDATION_FAILED || stopped == ISaveConstants.SAVE_FAILED) && !javascriptStop) {
IApplication application = fsm.getApplication();
Solution solution = application.getSolution();
int mid = solution.getOnAutoSaveFailedMethodID();
if (mid > 0) {
ScriptMethod sm = application.getFlattenedSolution().getScriptMethod(mid);
if (sm != null) {
// the validation failed in a none javascript stop (so this was an autosave failure)
List<JSRecordMarkers> failedMarkers = failedRecords.stream().map(record -> record.getRecordMarkers()).collect(Collectors.toList());
try {
application.getScriptEngine().getScopesScope().executeGlobalFunction(sm.getScopeName(), sm.getName(), Utils.arrayMerge((new Object[] { failedMarkers.toArray() }), Utils.parseJSExpressions(solution.getFlattenedMethodArguments(IContentSpecConstants.PROPERTY_ONAUTOSAVEDFAILEDMETHODID))), false, false);
} catch (Exception e) {
application.reportJSError("Failed to run the solutions auto save failed method", e);
}
} else {
application.reportJSWarning("Solution " + application.getSolutionName() + " onautosavefailed method not found for id " + mid);
}
}
}
return stopped;
}
use of com.servoy.j2db.persistence.Solution in project servoy-client by Servoy.
the class FoundSetManager method notifyDataChange.
/*
* _____________________________________________________________ dataNotification
*/
public void notifyDataChange(final String ds, IDataSet pks, final int action, Object[] insertColumnData) {
RowManager rm = rowManagers.get(ds);
if (rm != null) {
List<Row> insertedRows = null;
if (action == ISQLActionTypes.INSERT_ACTION && insertColumnData == null) {
// in this case the insert notification is probably triggered by rawSQL; so we need to read the new rows from DB to get correct newly inserted content
try {
insertedRows = rm.getRows(pks, 0, pks.getRowCount(), false);
if (insertedRows.size() != pks.getRowCount()) {
insertedRows = rm.getRows(pks, 0, pks.getRowCount(), true);
}
} catch (ServoyException e) {
Debug.error("Cannot get newly inserted rows.", e);
}
}
boolean didHaveRowAndIsUpdated = false;
IDataSet newPks = pks;
try {
// Convert the pk dataset to the column type of the pk columns
newPks = BufferedDataSetInternal.convertPksToRightType(pks, getTable(ds));
} catch (RepositoryException e) {
Debug.error(e);
}
final IDataSet fnewPks = newPks;
for (int i = 0; i < fnewPks.getRowCount(); i++) {
boolean b = rm.changeByOther(RowManager.createPKHashKey(fnewPks.getRow(i)), action, insertColumnData, insertedRows == null ? null : insertedRows.get(i));
didHaveRowAndIsUpdated = (didHaveRowAndIsUpdated || b);
}
// changed by other calls don't notify the table change for every row, call it once now.
notifyChange(rm.getSQLSheet().getTable());
final boolean didHaveDataCached = didHaveRowAndIsUpdated;
Runnable r = new Runnable() {
public void run() {
Solution solution = application.getSolution();
if (solution != null) {
ScriptMethod sm = application.getFlattenedSolution().getScriptMethod(solution.getOnDataBroadcastMethodID());
if (sm != null) {
try {
application.getScriptEngine().getScopesScope().executeGlobalFunction(sm.getScopeName(), sm.getName(), arrayMerge(new Object[] { ds, new Integer(action), new JSDataSet(application, fnewPks), Boolean.valueOf(didHaveDataCached) }, // $NON-NLS-1$
parseJSExpressions(solution.getFlattenedMethodArguments("onDataBroadcastMethodID"))), false, false);
} catch (Exception e1) {
application.reportError(Messages.getString("servoy.foundsetManager.error.ExecutingDataBroadcastMethod", new Object[] { sm.getName() }), // $NON-NLS-1$
e1);
}
}
}
}
};
application.invokeLater(r);
if (didHaveRowAndIsUpdated) {
if (infoListener != null)
infoListener.showDataChange();
} else // TODO if(action == INSERT) This is called to often now.
{
fireTableEvent(rm.getSQLSheet().getTable());
}
}
}
Aggregations