Search in sources :

Example 11 with ScriptNameValidator

use of com.servoy.j2db.persistence.ScriptNameValidator in project servoy-client by Servoy.

the class JSCalculation method setCode.

@JSSetter
public void setCode(String code) {
    checkModification();
    String name = JSMethod.parseName(code);
    if (!name.equals(scriptCalculation.getName())) {
        try {
            scriptCalculation.updateName(new ScriptNameValidator(application.getFlattenedSolution()), name);
        } catch (RepositoryException e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            throw new RuntimeException("Error updating the name from " + scriptCalculation.getName() + " to " + name, e);
        }
    }
    scriptCalculation.setDeclaration(code);
    try {
        TableScope tableScope = (TableScope) application.getScriptEngine().getTableScope(scriptCalculation.getTable());
        if (tableScope != null) {
            tableScope.put(scriptCalculation, scriptCalculation);
            String dataSource = scriptCalculation.getTable().getDataSource();
            FoundSetManager fsm = (FoundSetManager) application.getFoundSetManager();
            fsm.flushSQLSheet(dataSource);
            fsm.getRowManager(dataSource).clearCalcs(null, Arrays.asList(scriptCalculation.getName()));
        }
    } catch (ServoyException e) {
        Debug.error(e);
    }
}
Also used : FoundSetManager(com.servoy.j2db.dataprocessing.FoundSetManager) TableScope(com.servoy.j2db.scripting.TableScope) RepositoryException(com.servoy.j2db.persistence.RepositoryException) ScriptNameValidator(com.servoy.j2db.persistence.ScriptNameValidator) ServoyException(com.servoy.j2db.util.ServoyException) JSSetter(org.mozilla.javascript.annotations.JSSetter)

Example 12 with ScriptNameValidator

use of com.servoy.j2db.persistence.ScriptNameValidator in project servoy-client by Servoy.

the class JSVariable method setName.

@JSSetter
public void setName(String name) {
    checkModification();
    if (!name.equals(variable.getName())) {
        try {
            variable.updateName(new ScriptNameValidator(application.getFlattenedSolution()), name);
            refreshVariableInScope();
        } catch (RepositoryException e) {
            // $NON-NLS-1$ //$NON-NLS-2$
            throw new RuntimeException("Error updating the name from " + variable.getName() + " to " + name, e);
        }
    }
}
Also used : RepositoryException(com.servoy.j2db.persistence.RepositoryException) ScriptNameValidator(com.servoy.j2db.persistence.ScriptNameValidator) JSSetter(org.mozilla.javascript.annotations.JSSetter)

Aggregations

ScriptNameValidator (com.servoy.j2db.persistence.ScriptNameValidator)12 RepositoryException (com.servoy.j2db.persistence.RepositoryException)11 JSFunction (org.mozilla.javascript.annotations.JSFunction)7 FlattenedSolution (com.servoy.j2db.FlattenedSolution)5 FoundSetManager (com.servoy.j2db.dataprocessing.FoundSetManager)3 ScriptMethod (com.servoy.j2db.persistence.ScriptMethod)3 JSSetter (org.mozilla.javascript.annotations.JSSetter)3 IGlobalValueEntry (com.servoy.j2db.dataprocessing.IGlobalValueEntry)2 IRootObject (com.servoy.j2db.persistence.IRootObject)2 ScriptVariable (com.servoy.j2db.persistence.ScriptVariable)2 TableNode (com.servoy.j2db.persistence.TableNode)2 TableScope (com.servoy.j2db.scripting.TableScope)2 JSONObject (org.json.JSONObject)2 AbstractBase (com.servoy.j2db.persistence.AbstractBase)1 Column (com.servoy.j2db.persistence.Column)1 Element (com.servoy.j2db.persistence.ContentSpec.Element)1 IColumn (com.servoy.j2db.persistence.IColumn)1 IPersist (com.servoy.j2db.persistence.IPersist)1 IPersistVisitor (com.servoy.j2db.persistence.IPersistVisitor)1 IScriptElement (com.servoy.j2db.persistence.IScriptElement)1