Skip to content
Permalink
Browse files

NCubeRuntime.createCube / updateCube() implemented to allow them to b…

…e called from the NCubeContoller.
  • Loading branch information...
jdereg committed Nov 7, 2019
1 parent d38468f commit 4d3d5c1a8b3dfc39f90874136f31ffb5578548ae
@@ -73,11 +73,11 @@

<properties>
<version.json-io>4.11.0</version.json-io>
<version.java-util>1.37.0</version.java-util>
<version.java-util>1.38.0</version.java-util>
<version.json-command-servlet>1.8.3</version.json-command-servlet>
<version.guava>28.1-jre</version.guava>
<version.httpclient>4.5.10</version.httpclient>
<version.spring>5.1.10.RELEASE</version.spring>
<version.spring>5.2.1.RELEASE</version.spring>
<version.mysql.connector.java>8.0.17</version.mysql.connector.java>
<version.hsqldb>2.5.0</version.hsqldb>
<version.apache.ivy>2.4.0</version.apache.ivy>
@@ -220,7 +220,7 @@ class NCubeConfiguration
}

@Profile('test-database')
@Bean(name = 'hsqlSetup')
@Bean('hsqlSetup')
HsqlSchemaCreator getSchemaCreator()
{
HsqlSchemaCreator schemaCreator = new HsqlSchemaCreator(
@@ -249,13 +249,14 @@ class NCubeManager implements NCubeMutableClient, NCubeTestServer
}

@Transactional
void createCube(ApplicationID appId, String cubeName, byte[] cubeBytes)
NCube createCube(ApplicationID appId, String cubeName, byte[] cubeBytes)
{
NCube ncube = NCube.createCubeFromBytes(cubeBytes)
ncube.applicationID = appId
ncube.name = cubeName
createPermissionsCubesIfNewAppId(ncube.applicationID)
persister.createCube(ncube, getUserId())
return ncube
}

/**
@@ -42,7 +42,7 @@ interface NCubeMutableClient extends NCubeClient

void createCube(NCube ncube)

void createCube(ApplicationID appId, String cubeName, byte[] cubeBytes)
NCube createCube(ApplicationID appId, String cubeName, byte[] cubeBytes)

Boolean duplicate(ApplicationID oldAppId, ApplicationID newAppId, String oldName, String newName)

@@ -482,7 +482,14 @@ class NCubeRuntime implements NCubeMutableClient, NCubeRuntimeClient, NCubeTestC

Boolean updateCube(ApplicationID appId, String cubeName, byte[] cubeBytes)
{
throw new IllegalStateException('This should never be called. Call updateCube(NCube) instead.')
verifyAllowMutable('updateCube')
Boolean result = bean.call(beanName, 'updateCube', [appId, cubeName, cubeBytes]) as Boolean
if (SYS_CLASSPATH.equalsIgnoreCase(cubeName))
{ // If the sys.classpath cube is changed, then the entire class loader must be dropped. It will be lazily rebuilt.
clearCache(appId)
}
clearCache(appId, [cubeName])
return result
}

NCube loadCubeById(long id, Map options = null)
@@ -501,6 +508,11 @@ class NCubeRuntime implements NCubeMutableClient, NCubeRuntimeClient, NCubeTestC
return ncube
}

/**
* Called from Tests to create NCubes from resource (.json) files. Also could be called from a Java client
* that is running with 'ncube.allow.mutable' true.
* @param ncube NCube to create.
*/
void createCube(NCube ncube)
{
verifyAllowMutable('createCube')
@@ -509,9 +521,13 @@ class NCubeRuntime implements NCubeMutableClient, NCubeRuntimeClient, NCubeTestC
prepareCube(ncube)
}

void createCube(ApplicationID appId, String cubeName, byte[] cubeBytes)
NCube createCube(ApplicationID appId, String cubeName, byte[] cubeBytes)
{
throw new IllegalStateException('This should never be called. Call createCube(NCube) instead.')
verifyAllowMutable('createCube')
NCube ncube = (NCube)bean.call(beanName, 'createCube', [appId, cubeName, cubeBytes])
ncube.removeMetaProperty(NCube.METAPROPERTY_TEST_DATA)
prepareCube(ncube)
return ncube
}

Boolean duplicate(ApplicationID oldAppId, ApplicationID newAppId, String oldName, String newName)

0 comments on commit 4d3d5c1

Please sign in to comment.
You can’t perform that action at this time.