[DEV] udpate to the new interfaces and generic JPA

This commit is contained in:
Edouard DUPIN 2023-10-15 23:36:57 +02:00
parent 4f8a34590e
commit 00295b94d1
15 changed files with 181 additions and 143 deletions

View File

@ -27,7 +27,6 @@
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes> <attributes>
<attribute name="module" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>

View File

@ -8,6 +8,8 @@ import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.jackson.JacksonFeature; import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
import org.kar.archidata.GlobalConfiguration; import org.kar.archidata.GlobalConfiguration;
import org.kar.archidata.backup.BackupEngine;
import org.kar.archidata.backup.BackupEngine.StoreMode;
//import org.kar.archidata.model.Migration; //import org.kar.archidata.model.Migration;
import org.kar.archidata.catcher.ExceptionCatcher; import org.kar.archidata.catcher.ExceptionCatcher;
import org.kar.archidata.catcher.FailException404API; import org.kar.archidata.catcher.FailException404API;
@ -17,7 +19,7 @@ import org.kar.archidata.catcher.SystemExceptionCatcher;
import org.kar.archidata.filter.CORSFilter; import org.kar.archidata.filter.CORSFilter;
import org.kar.archidata.filter.OptionFilter; import org.kar.archidata.filter.OptionFilter;
import org.kar.archidata.migration.MigrationEngine; import org.kar.archidata.migration.MigrationEngine;
import org.kar.archidata.sqlWrapper.GenericAddOn; import org.kar.archidata.migration.MigrationModel;
import org.kar.archidata.util.ConfigBaseVariable; import org.kar.archidata.util.ConfigBaseVariable;
import org.kar.archidata.util.JWTWrapper; import org.kar.archidata.util.JWTWrapper;
import org.kar.karso.api.ApplicationResource; import org.kar.karso.api.ApplicationResource;
@ -30,6 +32,13 @@ import org.kar.karso.api.SystemConfigResource;
import org.kar.karso.api.UserResource; import org.kar.karso.api.UserResource;
import org.kar.karso.filter.KarsoAuthenticationFilter; import org.kar.karso.filter.KarsoAuthenticationFilter;
import org.kar.karso.migration.Initialization; import org.kar.karso.migration.Initialization;
import org.kar.karso.migration.Migration20231015;
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.util.ConfigVariable; import org.kar.karso.util.ConfigVariable;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -40,10 +49,19 @@ public class WebLauncher {
private final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class); private final static Logger LOGGER = LoggerFactory.getLogger(WebLauncher.class);
protected ResourceConfig rc = null; protected ResourceConfig rc = null;
HttpServer server = null; HttpServer server = null;
protected BackupEngine backupEngine = new BackupEngine("./backup", StoreMode.JSON);
public WebLauncher() { public WebLauncher() {
ConfigBaseVariable.bdDatabase = "karso"; ConfigBaseVariable.bdDatabase = "karso";
GenericAddOn.addGenericAddOn();
backupEngine.addClass(MigrationModel.class);
backupEngine.addClass(Settings.class);
backupEngine.addClass(UserAuth.class);
backupEngine.addClass(Application.class);
backupEngine.addClass(ApplicationToken.class);
backupEngine.addClass(RightDescription.class);
backupEngine.addClass(Right.class);
} }
private static URI getBaseURI() { private static URI getBaseURI() {
@ -66,6 +84,7 @@ public class WebLauncher {
final MigrationEngine migrationEngine = new MigrationEngine(); final MigrationEngine migrationEngine = new MigrationEngine();
WebLauncher.LOGGER.info("Add initialization"); WebLauncher.LOGGER.info("Add initialization");
migrationEngine.setInit(new Initialization()); migrationEngine.setInit(new Initialization());
migrationEngine.add(new Migration20231015());
WebLauncher.LOGGER.info("Add migration since last version"); WebLauncher.LOGGER.info("Add migration since last version");
// NOTHING for now // NOTHING for now
WebLauncher.LOGGER.info("Migrate the DB [START]"); WebLauncher.LOGGER.info("Migrate the DB [START]");

View File

@ -11,7 +11,7 @@ import org.kar.archidata.filter.GenericContext;
import org.kar.archidata.sqlWrapper.QuerryAnd; import org.kar.archidata.sqlWrapper.QuerryAnd;
import org.kar.archidata.sqlWrapper.QuerryCondition; import org.kar.archidata.sqlWrapper.QuerryCondition;
import org.kar.archidata.sqlWrapper.SqlWrapper; import org.kar.archidata.sqlWrapper.SqlWrapper;
import org.kar.archidata.sqlWrapper.addOn.AddOnSQLTableExternalLink; import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
import org.kar.archidata.util.JWTWrapper; import org.kar.archidata.util.JWTWrapper;
import org.kar.karso.model.Application; import org.kar.karso.model.Application;
import org.kar.karso.model.ApplicationSmall; import org.kar.karso.model.ApplicationSmall;
@ -46,7 +46,7 @@ public class ApplicationResource {
final List<Long> out = new ArrayList<>(); final List<Long> out = new ArrayList<>();
List<UserLinkApplication> links = null; List<UserLinkApplication> links = null;
try { try {
links = SqlWrapper.getsWhere(UserLinkApplication.class, new QuerryAnd(new QuerryCondition("user_id", "=", userId), new QuerryCondition("deleted", "=", 0)), false); links = SqlWrapper.getsWhere(UserLinkApplication.class, new QuerryCondition("user_id", "=", userId));
} catch (final Exception e) { } catch (final Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -64,7 +64,7 @@ public class ApplicationResource {
final List<Long> out = new ArrayList<>(); final List<Long> out = new ArrayList<>();
List<UserLinkApplication> links = null; List<UserLinkApplication> links = null;
try { try {
links = SqlWrapper.getsWhere(UserLinkApplication.class, new QuerryAnd(new QuerryCondition("application_id", "=", applicationId), new QuerryCondition("deleted", "=", 0)), false); links = SqlWrapper.getsWhere(UserLinkApplication.class, new QuerryCondition("application_id", "=", applicationId));
} catch (final Exception e) { } catch (final Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -90,7 +90,7 @@ public class ApplicationResource {
final GenericContext gc = (GenericContext) sc.getUserPrincipal(); final GenericContext gc = (GenericContext) sc.getUserPrincipal();
this.logger.debug("getApplications"); this.logger.debug("getApplications");
// TODO filter with the list of element available in his authorizations ... // TODO filter with the list of element available in his authorizations ...
final List<Application> tmp = SqlWrapper.gets(Application.class, false); final List<Application> tmp = SqlWrapper.gets(Application.class);
if (gc.userByToken.hasRight("ADMIN", true)) { if (gc.userByToken.hasRight("ADMIN", true)) {
return tmp; return tmp;
} }
@ -116,9 +116,9 @@ public class ApplicationResource {
throw new InputException("redirect", "create application (redirect too small: '" + application.redirect + "')"); throw new InputException("redirect", "create application (redirect too small: '" + application.redirect + "')");
} }
application.id = null; application.id = null;
application.create_date = null; application.createdAt = null;
application.deleted = null; application.deleted = null;
application.modify_date = null; application.updatedAt = null;
return SqlWrapper.insert(application); return SqlWrapper.insert(application);
} }
@ -149,7 +149,7 @@ public class ApplicationResource {
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
@Produces(value = MediaType.TEXT_PLAIN) @Produces(value = MediaType.TEXT_PLAIN)
public void remove(@Context final SecurityContext sc, @PathParam("id") final long applicationId) throws Exception { public void remove(@Context final SecurityContext sc, @PathParam("id") final long applicationId) throws Exception {
SqlWrapper.setDelete(Application.class, applicationId); SqlWrapper.delete(Application.class, applicationId);
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -180,7 +180,7 @@ public class ApplicationResource {
public List<ApplicationSmall> getApplicationsSmall(@Context final SecurityContext sc) throws Exception { public List<ApplicationSmall> getApplicationsSmall(@Context final SecurityContext sc) throws Exception {
final GenericContext gc = (GenericContext) sc.getUserPrincipal(); final GenericContext gc = (GenericContext) sc.getUserPrincipal();
this.logger.debug("getApplications"); this.logger.debug("getApplications");
final List<Application> tmp = SqlWrapper.gets(Application.class, false); final List<Application> tmp = SqlWrapper.gets(Application.class);
final List<Long> regular = getUserListOfApplication(gc.userByToken.id); final List<Long> regular = getUserListOfApplication(gc.userByToken.id);
final List<ApplicationSmall> out = new ArrayList<>(); final List<ApplicationSmall> out = new ArrayList<>();
for (final Application app : tmp) { for (final Application app : tmp) {
@ -200,7 +200,7 @@ public class ApplicationResource {
@RolesAllowed(value = { "ADMIN" }) @RolesAllowed(value = { "ADMIN" })
public boolean addUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception { public boolean addUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception {
this.logger.debug("getApplications"); this.logger.debug("getApplications");
AddOnSQLTableExternalLink.addLink(UserAuth.class, data.userId, "application", applicationId); AddOnManyToMany.addLink(UserAuth.class, data.userId, "application", applicationId);
return true; return true;
} }
@ -210,7 +210,7 @@ public class ApplicationResource {
@RolesAllowed(value = { "ADMIN" }) @RolesAllowed(value = { "ADMIN" })
public boolean rmUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception { public boolean rmUser(@PathParam("id") final Long applicationId, final AddUserData data) throws Exception {
this.logger.debug("getApplications"); this.logger.debug("getApplications");
AddOnSQLTableExternalLink.removeLink(UserAuth.class, data.userId, "application", applicationId); AddOnManyToMany.removeLink(UserAuth.class, data.userId, "application", applicationId);
return true; return true;
} }
@ -220,7 +220,7 @@ public class ApplicationResource {
@RolesAllowed(value = { "ADMIN" }) @RolesAllowed(value = { "ADMIN" })
public List<RightDescription> getRightsDescription(@PathParam("id") final Long applicationId) throws Exception { public List<RightDescription> getRightsDescription(@PathParam("id") final Long applicationId) throws Exception {
this.logger.debug("getApplications rights"); this.logger.debug("getApplications rights");
return SqlWrapper.getsWhere(RightDescription.class, new QuerryCondition("applicationId", "=", applicationId), false); return SqlWrapper.getsWhere(RightDescription.class, new QuerryCondition("applicationId", "=", applicationId));
} }
@GET @GET
@ -246,7 +246,7 @@ public class ApplicationResource {
Application appl = null; Application appl = null;
try { try {
appl = SqlWrapper.getWhere(Application.class, new QuerryCondition("name", "=", applicationName), false); appl = SqlWrapper.getWhere(Application.class, new QuerryCondition("name", "=", applicationName));
} catch (final Exception e) { } catch (final Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -263,7 +263,7 @@ public class ApplicationResource {
UserLinkApplication links = null; UserLinkApplication links = null;
try { try {
links = SqlWrapper.getWhere(UserLinkApplication.class, links = SqlWrapper.getWhere(UserLinkApplication.class,
new QuerryAnd(new QuerryCondition("user_id", "=", gc.userByToken.id), new QuerryCondition("deleted", "=", 0), new QuerryCondition("application_id", "=", appl.id)), false); new QuerryAnd(new QuerryCondition("user_id", "=", gc.userByToken.id), new QuerryCondition("deleted", "=", 0), new QuerryCondition("application_id", "=", appl.id)));
} catch (final Exception e) { } catch (final Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();

View File

@ -42,7 +42,7 @@ public class ApplicationTokenResource {
@Path("{applicationId}") @Path("{applicationId}")
@RolesAllowed(value = { "ADMIN" }) @RolesAllowed(value = { "ADMIN" })
public List<ApplicationToken> gets(@Context final SecurityContext sc, @PathParam("applicationId") final Long applicationId) throws Exception { public List<ApplicationToken> gets(@Context final SecurityContext sc, @PathParam("applicationId") final Long applicationId) throws Exception {
final List<ApplicationToken> values = SqlWrapper.getsWhere(ApplicationToken.class, new QuerryCondition("parentId", "=", applicationId), false); final List<ApplicationToken> values = SqlWrapper.getsWhere(ApplicationToken.class, new QuerryCondition("parentId", "=", applicationId));
// clean all tokens this is a secret: // clean all tokens this is a secret:
for (final ApplicationToken elem : values) { for (final ApplicationToken elem : values) {
elem.token = null; elem.token = null;

View File

@ -31,12 +31,11 @@ public class RightResource {
final static Logger logger = LoggerFactory.getLogger(RightResource.class); final static Logger logger = LoggerFactory.getLogger(RightResource.class);
public static List<RightDescription> getApplicationRightDecription(final long applicationId) throws Exception { public static List<RightDescription> getApplicationRightDecription(final long applicationId) throws Exception {
return SqlWrapper.getsWhere(RightDescription.class, new QuerryAnd(new QuerryCondition("applicationId", "=", applicationId), new QuerryCondition("deleted", "=", 0))); return SqlWrapper.getsWhere(RightDescription.class, new QuerryCondition("applicationId", "=", applicationId));
} }
public static List<Right> getRawUserRight(final long userId, final long applicationId) throws Exception { public static List<Right> getRawUserRight(final long userId, final long applicationId) throws Exception {
return SqlWrapper.getsWhere(Right.class, return SqlWrapper.getsWhere(Right.class, new QuerryAnd(new QuerryCondition("applicationId", "=", applicationId), new QuerryCondition("userId", "=", userId)));
new QuerryAnd(new QuerryCondition("applicationId", "=", applicationId), new QuerryCondition("userId", "=", userId), new QuerryCondition("deleted", "=", 0)));
} }
public static Map<String, Object> getUserRight(final long userId, final long applicationId) throws Exception { public static Map<String, Object> getUserRight(final long userId, final long applicationId) throws Exception {
@ -111,7 +110,7 @@ public class RightResource {
@GET @GET
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public List<Right> get() throws Exception { public List<Right> get() throws Exception {
return SqlWrapper.gets(Right.class, false); return SqlWrapper.gets(Right.class);
} }
@POST @POST
@ -141,7 +140,7 @@ public class RightResource {
@Path("{id}") @Path("{id}")
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public Response delete(@PathParam("id") final Long id) throws Exception { public Response delete(@PathParam("id") final Long id) throws Exception {
SqlWrapper.setDelete(Right.class, id); SqlWrapper.delete(Right.class, id);
return Response.ok().build(); return Response.ok().build();
} }

View File

@ -49,7 +49,7 @@ public class SystemConfigResource {
@Path("is_sign_up_availlable") @Path("is_sign_up_availlable")
@PermitAll @PermitAll
public GetSignUpAvaillable isSignUpAvaillable() throws Exception { public GetSignUpAvaillable isSignUpAvaillable() throws Exception {
final Settings set = SqlWrapper.getWhere(Settings.class, new QuerryCondition("key", "=", "SIGN_UP_ENABLE"), false); final Settings set = SqlWrapper.getWhere(Settings.class, new QuerryCondition("key", "=", "SIGN_UP_ENABLE"));
if (set == null) { if (set == null) {
throw new NotFoundException("Value does not exist"); throw new NotFoundException("Value does not exist");
} }
@ -63,7 +63,7 @@ public class SystemConfigResource {
@Path("key/{key}") @Path("key/{key}")
@RolesAllowed(value = { "USER", "ADMIN" }) @RolesAllowed(value = { "USER", "ADMIN" })
public Response getKey(@Context final SecurityContext sc, @PathParam("key") final String key) throws Exception { public Response getKey(@Context final SecurityContext sc, @PathParam("key") final String key) throws Exception {
final Settings set = SqlWrapper.getWhere(Settings.class, new QuerryCondition("key", "=", key), false); final Settings set = SqlWrapper.getWhere(Settings.class, new QuerryCondition("key", "=", key));
if (set == null) { if (set == null) {
throw new NotFoundException("Value does not exist"); throw new NotFoundException("Value does not exist");
} }
@ -85,7 +85,7 @@ public class SystemConfigResource {
public Response setKey(@Context final SecurityContext sc, @PathParam("key") final String key, final String jsonRequest) throws Exception { public Response setKey(@Context final SecurityContext sc, @PathParam("key") final String key, final String jsonRequest) throws Exception {
Settings res = null; Settings res = null;
try { try {
res = SqlWrapper.getWhere(Settings.class, new QuerryCondition("key", "=", key), false); res = SqlWrapper.getWhere(Settings.class, new QuerryCondition("key", "=", key));
} catch (final Exception e) { } catch (final Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();

View File

@ -18,7 +18,7 @@ import org.kar.archidata.filter.GenericContext;
import org.kar.archidata.model.GetToken; import org.kar.archidata.model.GetToken;
import org.kar.archidata.sqlWrapper.QuerryCondition; import org.kar.archidata.sqlWrapper.QuerryCondition;
import org.kar.archidata.sqlWrapper.SqlWrapper; import org.kar.archidata.sqlWrapper.SqlWrapper;
import org.kar.archidata.sqlWrapper.addOn.AddOnSQLTableExternalLink; import org.kar.archidata.sqlWrapper.addOn.AddOnManyToMany;
import org.kar.archidata.util.JWTWrapper; import org.kar.archidata.util.JWTWrapper;
import org.kar.karso.migration.Initialization; import org.kar.karso.migration.Initialization;
import org.kar.karso.model.ChangePassword; import org.kar.karso.model.ChangePassword;
@ -68,7 +68,7 @@ public class UserResource {
@GET @GET
@RolesAllowed("ADMIN") @RolesAllowed("ADMIN")
public List<UserAuthGet> getUsers() throws Exception { public List<UserAuthGet> getUsers() throws Exception {
return SqlWrapper.gets(UserAuthGet.class, false); return SqlWrapper.gets(UserAuthGet.class);
} }
@GET @GET
@ -86,9 +86,9 @@ public class UserResource {
throws Exception { throws Exception {
this.logger.debug("Find typeNode"); this.logger.debug("Find typeNode");
if (data) { if (data) {
AddOnSQLTableExternalLink.addLink(UserAuth.class, userId, "application", applicationId); AddOnManyToMany.addLink(UserAuth.class, userId, "application", applicationId);
} else { } else {
AddOnSQLTableExternalLink.removeLink(UserAuth.class, userId, "application", applicationId); AddOnManyToMany.removeLink(UserAuth.class, userId, "application", applicationId);
} }
return SqlWrapper.get(UserAuth.class, userId); return SqlWrapper.get(UserAuth.class, userId);
} }
@ -159,12 +159,12 @@ public class UserResource {
// TODO: verify if the data are a hash ... // TODO: verify if the data are a hash ...
// Check login does not exist // Check login does not exist
List<UserAuth> out = SqlWrapper.getsWhere(UserAuth.class, new QuerryCondition("login", "=", user.login), false); List<UserAuth> out = SqlWrapper.getsWhere(UserAuth.class, new QuerryCondition("login", "=", user.login));
if (out.size() >= 1) { if (out.size() >= 1) {
throw new FailException(Response.Status.BAD_REQUEST, "Login already used !!!"); throw new FailException(Response.Status.BAD_REQUEST, "Login already used !!!");
} }
// Check email does not exist // Check email does not exist
out = SqlWrapper.getsWhere(UserAuth.class, new QuerryCondition("email", "=", user.email), false); out = SqlWrapper.getsWhere(UserAuth.class, new QuerryCondition("email", "=", user.email));
if (out.size() >= 1) { if (out.size() >= 1) {
throw new FailException(Response.Status.BAD_REQUEST, "e-mail already used !!!"); throw new FailException(Response.Status.BAD_REQUEST, "e-mail already used !!!");
} }
@ -240,7 +240,7 @@ public class UserResource {
@PermitAll @PermitAll
public Response checkLogin(@QueryParam("login") final String login) throws Exception { public Response checkLogin(@QueryParam("login") final String login) throws Exception {
this.logger.debug("checkLogin: '{}'", login); this.logger.debug("checkLogin: '{}'", login);
final List<UserAuth> out = SqlWrapper.getsWhere(UserAuth.class, new QuerryCondition("login", "=", login), false); final List<UserAuth> out = SqlWrapper.getsWhere(UserAuth.class, new QuerryCondition("login", "=", login));
if (out.size() >= 1) { if (out.size() >= 1) {
return Response.ok().build(); return Response.ok().build();
} }
@ -253,7 +253,7 @@ public class UserResource {
@PermitAll @PermitAll
public Response checkEmail(@QueryParam("email") final String email) throws Exception { public Response checkEmail(@QueryParam("email") final String email) throws Exception {
this.logger.debug("checkEmail: {}", email); this.logger.debug("checkEmail: {}", email);
final List<UserAuth> out = SqlWrapper.getsWhere(UserAuth.class, new QuerryCondition("email", "=", email), false); final List<UserAuth> out = SqlWrapper.getsWhere(UserAuth.class, new QuerryCondition("email", "=", email));
if (out.size() >= 1) { if (out.size() >= 1) {
return Response.ok().build(); return Response.ok().build();
} }
@ -277,7 +277,7 @@ public class UserResource {
if (login.contains("@")) { if (login.contains("@")) {
query = "email"; query = "email";
} }
final UserAuth user = SqlWrapper.getWhere(UserAuth.class, new QuerryCondition(query, "=", login), false); final UserAuth user = SqlWrapper.getWhere(UserAuth.class, new QuerryCondition(query, "=", login));
if (user == null) { if (user == null) {
throw new FailException(Response.Status.PRECONDITION_FAILED, "FAIL Authentiocate-wrong email/login '" + login + "')"); throw new FailException(Response.Status.PRECONDITION_FAILED, "FAIL Authentiocate-wrong email/login '" + login + "')");

View File

@ -0,0 +1,30 @@
package org.kar.karso.migration;
import java.util.List;
import org.kar.archidata.migration.MigrationSqlStep;
public class Migration20231015 extends MigrationSqlStep {
public static final int KARSO_INITIALISATION_ID = 1;
@Override
public String getName() {
return "refactor creation and update time";
}
public Migration20231015() throws Exception {
for (String elem : List.of("application", "applicationToken", "right", "rightDescription", "settings", "user", "user_link_application", "user_link_cover")) {
addAction("""
ALTER TABLE `""" + elem + """
`
RENAME COLUMN `create_date` TO `createdAt`,
RENAME COLUMN `modify_date` TO `updatedAt`;
""");
}
display();
}
}

View File

@ -1,23 +1,11 @@
package org.kar.karso.model; package org.kar.karso.model;
/*
CREATE TABLE `application` (
`id` bigint NOT NULL COMMENT 'Unique ID of the application' AUTO_INCREMENT PRIMARY KEY,
`description` text COMMENT 'description of the application',
`token` varchar(128) COLLATE 'latin1_bin' NOT NULL COMMENT 'Token (can be not unique)'
) AUTO_INCREMENT=10;
*/
public class ApplicationSmall { public class ApplicationSmall {
public String name; public String name;
public String description; public String description;
public String redirect; public String redirect;
public ApplicationSmall() { public ApplicationSmall() {}
}
public ApplicationSmall(String name, String description, String redirect) { public ApplicationSmall(String name, String description, String redirect) {
super(); super();

View File

@ -1,13 +1,14 @@
package org.kar.karso.model; package org.kar.karso.model;
import org.kar.archidata.annotation.SQLComment; import org.kar.archidata.annotation.SQLComment;
import org.kar.archidata.annotation.SQLForeignKey;
import org.kar.archidata.annotation.SQLIfNotExists; import org.kar.archidata.annotation.SQLIfNotExists;
import org.kar.archidata.model.GenericTable; import org.kar.archidata.model.GenericTable;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
@Table(name = "right") @Table(name = "right")
@ -17,15 +18,15 @@ public class Right extends GenericTable {
@Column(nullable = false) @Column(nullable = false)
@SQLComment("application-ID that have the reference of the right") @SQLComment("application-ID that have the reference of the right")
@SQLForeignKey("application") @ManyToOne(fetch = FetchType.LAZY, targetEntity = Application.class)
public long applicationId; public long applicationId;
@Column(nullable = false) @Column(nullable = false)
@SQLComment("user-ID ") @SQLComment("user-ID ")
@SQLForeignKey("user") @ManyToOne(fetch = FetchType.LAZY, targetEntity = UserAuth.class)
public long userId; public long userId;
@Column(nullable = false) @Column(nullable = false)
@SQLComment("rightDescription-ID of the right description") @SQLComment("rightDescription-ID of the right description")
@SQLForeignKey("rightDescription") @ManyToOne(fetch = FetchType.LAZY, targetEntity = RightDescription.class)
public long rightDescriptionId; public long rightDescriptionId;
@Column(length = 1024, nullable = false) @Column(length = 1024, nullable = false)
@SQLComment("Value of the right") @SQLComment("Value of the right")

View File

@ -2,13 +2,14 @@ package org.kar.karso.model;
import org.kar.archidata.annotation.SQLComment; import org.kar.archidata.annotation.SQLComment;
import org.kar.archidata.annotation.SQLDefault; import org.kar.archidata.annotation.SQLDefault;
import org.kar.archidata.annotation.SQLForeignKey;
import org.kar.archidata.annotation.SQLIfNotExists; import org.kar.archidata.annotation.SQLIfNotExists;
import org.kar.archidata.model.GenericTable; import org.kar.archidata.model.GenericTable;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
@Table(name = "rightDescription") @Table(name = "rightDescription")
@ -17,7 +18,7 @@ import jakarta.persistence.Table;
public class RightDescription extends GenericTable { public class RightDescription extends GenericTable {
@Column(nullable = false) @Column(nullable = false)
@SQLComment("Application id that have the reference of the right") @SQLComment("Application id that have the reference of the right")
@SQLForeignKey("application") @ManyToOne(fetch = FetchType.LAZY, targetEntity = Application.class)
public long applicationId; public long applicationId;
@Column(length = 64, nullable = false) @Column(length = 64, nullable = false)
@SQLComment("Key of the property") @SQLComment("Key of the property")

View File

@ -6,12 +6,12 @@ import java.util.List;
import org.kar.archidata.annotation.SQLComment; import org.kar.archidata.annotation.SQLComment;
import org.kar.archidata.annotation.SQLDefault; import org.kar.archidata.annotation.SQLDefault;
import org.kar.archidata.annotation.SQLIfNotExists; import org.kar.archidata.annotation.SQLIfNotExists;
import org.kar.archidata.annotation.addOn.SQLTableExternalLink;
import org.kar.archidata.model.User; import org.kar.archidata.model.User;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
@Table(name = "user") @Table(name = "user")
@ -35,7 +35,7 @@ public class UserAuth extends User {
@Column(nullable = false) @Column(nullable = false)
public boolean avatar = false; public boolean avatar = false;
@SQLComment("List of accessible application (if not set the application is not available)") @SQLComment("List of accessible application (if not set the application is not available)")
@SQLTableExternalLink @ManyToMany(targetEntity = Application.class)
public List<Long> applications = null; public List<Long> applications = null;
} }

View File

@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.persistence.Table; import jakarta.persistence.Table;
// TODO: reùmove this, it must be generated instead of manually create ///
@Table(name = "user_link_application") @Table(name = "user_link_application")
@SQLIfNotExists @SQLIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)

View File

@ -5,8 +5,8 @@
"scripts": { "scripts": {
"all": "npm run build && npm run test", "all": "npm run build && npm run test",
"ng": "ng", "ng": "ng",
"start": "ng serve karso --configuration=develop --watch --port 4200", "dev": "ng serve karso --configuration=develop --watch --port 4200",
"start_edge": "ng serve karso-edge --configuration=develop --watch --port 4199", "dev_edge": "ng serve karso-edge --configuration=develop --watch --port 4199",
"build": "ng build karso --prod", "build": "ng build karso --prod",
"test": "ng test karso", "test": "ng test karso",
"test-coverage": "ng test karso --code-coverage", "test-coverage": "ng test karso --code-coverage",

@ -1 +1 @@
Subproject commit 9fc25b4feaeba509ff39f70b24d97be47f4b30e1 Subproject commit ea5a4f6b7537eb707916f4610bf79fbe86c6296f