[DEV] implement first model of migration interface
This commit is contained in:
parent
d10897a086
commit
03522c9f64
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="out/maven/classes" path="src">
|
||||
<classpathentry including="**/*.java" kind="src" output="out/maven/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
@ -30,5 +30,22 @@
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="out/maven/generated-sources/annotations">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="ignore_optional_problems" value="true"/>
|
||||
<attribute name="m2e-apt" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="out/maven/test-classes" path="out/maven/generated-test-sources/test-annotations">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="ignore_optional_problems" value="true"/>
|
||||
<attribute name="m2e-apt" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="out/maven/classes"/>
|
||||
</classpath>
|
||||
|
@ -2,6 +2,7 @@
|
||||
package org.kar.karso;
|
||||
|
||||
import org.kar.archidata.filter.OptionFilter;
|
||||
import org.kar.archidata.migration.MigrationEngine;
|
||||
import org.kar.karso.api.ApplicationResource;
|
||||
import org.kar.karso.api.ApplicationTokenResource;
|
||||
import org.kar.karso.api.Front;
|
||||
@ -11,22 +12,18 @@ import org.kar.karso.api.RightResource;
|
||||
import org.kar.karso.api.SystemConfigResource;
|
||||
import org.kar.karso.api.UserResource;
|
||||
import org.kar.karso.filter.KarsoAuthenticationFilter;
|
||||
import org.kar.karso.model.Application;
|
||||
import org.kar.karso.model.ApplicationToken;
|
||||
import org.kar.karso.model.Right;
|
||||
import org.kar.karso.model.RightDescription;
|
||||
import org.kar.karso.model.Settings;
|
||||
import org.kar.karso.model.UserAuth;
|
||||
import org.kar.karso.migration.Initialization;
|
||||
import org.kar.karso.util.ConfigVariable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.kar.archidata.GlobalConfiguration;
|
||||
//import org.kar.archidata.model.Migration;
|
||||
import org.kar.archidata.SqlWrapper;
|
||||
import org.kar.archidata.catcher.ExceptionCatcher;
|
||||
import org.kar.archidata.catcher.FailException404API;
|
||||
import org.kar.archidata.catcher.FailExceptionCatcher;
|
||||
import org.kar.archidata.catcher.InputExceptionCatcher;
|
||||
import org.kar.archidata.catcher.SystemExceptionCatcher;
|
||||
import org.kar.archidata.db.DBEntry;
|
||||
import org.kar.archidata.filter.CORSFilter;
|
||||
import org.kar.archidata.util.ConfigBaseVariable;
|
||||
import org.kar.archidata.util.JWTWrapper;
|
||||
@ -55,86 +52,10 @@ public class WebLauncher {
|
||||
WebLauncher.LOGGER.info("STOP the REST server:");
|
||||
}
|
||||
|
||||
public void generateDB() {
|
||||
|
||||
// generate the BDD:
|
||||
try {
|
||||
String out = "";
|
||||
out += SqlWrapper.createTable(Settings.class);
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
out += SqlWrapper.createTable(UserAuth.class);
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
out += SqlWrapper.createTable(Application.class);
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
out += SqlWrapper.createTable(ApplicationToken.class);
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
out += SqlWrapper.createTable(RightDescription.class);
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
out += SqlWrapper.createTable(Right.class);
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
// default admin: "karadmin" password: "adminA@666"
|
||||
out += """
|
||||
INSERT INTO `application` (`id`, `name`, `description`, `redirect`, `redirectDev`, `notification`, `ttl`) VALUES
|
||||
('0', 'karso', 'Root SSO interface', 'http://atria-soft/karso', '', '', '666');
|
||||
""";
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
out += """
|
||||
INSERT INTO `user` (`id`, `login`, `password`, `email`, `admin`) VALUES
|
||||
('0', 'karadmin', '0ddcac5ede3f1300a1ce5948ab15112f2810130531d578ab8bc4dc131652d7cf7a3ff6e827eb957bff43bc2c65a6a1d46722e5b3a2343ac3176a33ea7250080b',
|
||||
'admin@admin.ZZZ', 1);
|
||||
""";
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
out += """
|
||||
INSERT INTO `settings` (`key`, `right`, `type`, `value`) VALUES
|
||||
('SIGN_UP_ENABLE', 'rwr-r-', 'BOOLEAN', 'false'),
|
||||
('SIGN_IN_ENABLE', 'rwr-r-', 'BOOLEAN', 'true'),
|
||||
('SIGN_UP_FILTER', 'rw----', 'STRING', '.*'),
|
||||
('EMAIL_VALIDATION_REQUIRED', 'rwr-r-', 'BOOLEAN', 'false');
|
||||
""";
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
out += """
|
||||
INSERT INTO `rightDescription` (`id`, `applicationId`, `key`, `title`, `description`, `type`) VALUES
|
||||
(0, 0, 'ADMIN', 'Administrator', 'Full administrator Right', 'BOOLEAN');
|
||||
""";
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
out += """
|
||||
INSERT INTO `right` (`applicationId`, `userId`, `rightDescriptionId`, `value`) VALUES
|
||||
(0, 0, 0, 'true');
|
||||
""";
|
||||
LOGGER.debug(out);
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
out = "";
|
||||
//out += SqlWrapper.createTable(Migration.class);
|
||||
LOGGER.debug(out);
|
||||
|
||||
// Do initialization or migration:
|
||||
SqlWrapper.executeSimpleQuerry(out);
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
LOGGER.error("can not generate the BD: {}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void generateDB() throws Exception {
|
||||
MigrationEngine migrationEngine = new MigrationEngine();
|
||||
migrationEngine.setInit(new Initialization());
|
||||
migrationEngine.migrate(DBEntry.createInterface(GlobalConfiguration.dbConfig));
|
||||
}
|
||||
|
||||
public void process() throws InterruptedException {
|
||||
|
56
back/src/org/kar/karso/migration/Initialization.java
Normal file
56
back/src/org/kar/karso/migration/Initialization.java
Normal file
@ -0,0 +1,56 @@
|
||||
package org.kar.karso.migration;
|
||||
|
||||
import org.kar.archidata.migration.MigrationModel;
|
||||
import org.kar.archidata.migration.MigrationSqlStep;
|
||||
import org.kar.karso.model.Application;
|
||||
import org.kar.karso.model.ApplicationToken;
|
||||
import org.kar.karso.model.Right;
|
||||
import org.kar.karso.model.RightDescription;
|
||||
import org.kar.karso.model.Settings;
|
||||
import org.kar.karso.model.UserAuth;
|
||||
|
||||
public class Initialization extends MigrationSqlStep {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Initialization.class.getCanonicalName();
|
||||
}
|
||||
|
||||
public Initialization() throws Exception {
|
||||
|
||||
addClass(Settings.class);
|
||||
addClass(UserAuth.class);
|
||||
addClass(Application.class);
|
||||
addClass(ApplicationToken.class);
|
||||
addClass(RightDescription.class);
|
||||
addClass(Right.class);
|
||||
addClass(MigrationModel.class);
|
||||
|
||||
// default admin: "karadmin" password: "adminA@666"
|
||||
addAction("""
|
||||
INSERT INTO `application` (`id`, `name`, `description`, `redirect`, `redirectDev`, `notification`, `ttl`) VALUES
|
||||
('0', 'karso', 'Root SSO interface', 'http://atria-soft/karso', '', '', '666');
|
||||
""");
|
||||
addAction("""
|
||||
INSERT INTO `user` (`id`, `login`, `password`, `email`, `admin`) VALUES
|
||||
('0', 'karadmin', '0ddcac5ede3f1300a1ce5948ab15112f2810130531d578ab8bc4dc131652d7cf7a3ff6e827eb957bff43bc2c65a6a1d46722e5b3a2343ac3176a33ea7250080b',
|
||||
'admin@admin.ZZZ', 1);
|
||||
""");
|
||||
addAction("""
|
||||
INSERT INTO `settings` (`key`, `right`, `type`, `value`) VALUES
|
||||
('SIGN_UP_ENABLE', 'rwr-r-', 'BOOLEAN', 'false'),
|
||||
('SIGN_IN_ENABLE', 'rwr-r-', 'BOOLEAN', 'true'),
|
||||
('SIGN_UP_FILTER', 'rw----', 'STRING', '.*'),
|
||||
('EMAIL_VALIDATION_REQUIRED', 'rwr-r-', 'BOOLEAN', 'false');
|
||||
""");
|
||||
addAction("""
|
||||
INSERT INTO `rightDescription` (`id`, `applicationId`, `key`, `title`, `description`, `type`) VALUES
|
||||
(0, 0, 'ADMIN', 'Administrator', 'Full administrator Right', 'BOOLEAN');
|
||||
""");
|
||||
addAction("""
|
||||
INSERT INTO `right` (`applicationId`, `userId`, `rightDescriptionId`, `value`) VALUES
|
||||
(0, 0, 0, 'true');
|
||||
""");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user