[DEV] update New models done

This commit is contained in:
Edouard DUPIN 2023-11-27 22:29:16 +01:00
parent a78c3f5c1f
commit 4a8dfe3fb0
4 changed files with 27 additions and 23 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.kar</groupId> <groupId>org.kar</groupId>
<artifactId>karso</artifactId> <artifactId>karso</artifactId>
<version>0.4.3</version> <version>0.5.0</version>
<properties> <properties>
<maven.compiler.version>3.1</maven.compiler.version> <maven.compiler.version>3.1</maven.compiler.version>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
@ -20,12 +20,12 @@
<dependency> <dependency>
<groupId>kangaroo-and-rabbit</groupId> <groupId>kangaroo-and-rabbit</groupId>
<artifactId>archidata</artifactId> <artifactId>archidata</artifactId>
<version>0.4.0</version> <version>0.5.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId> <artifactId>slf4j-simple</artifactId>
<version>2.0.7</version> <version>2.0.9</version>
</dependency> </dependency>
<!-- <!--
************************************************************ ************************************************************
@ -35,13 +35,13 @@
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId> <artifactId>junit-jupiter-api</artifactId>
<version>5.10.0</version> <version>5.10.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId> <artifactId>junit-jupiter-engine</artifactId>
<version>5.10.0</version> <version>5.10.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -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 = DataAccess.getsWhere(UserLinkApplication.class, new QueryCondition("user_id", "=", userId)); links = DataAccess.getsWhere(UserLinkApplication.class, new QueryCondition("userId", "=", userId));
} catch (final Exception e) { } catch (final Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -55,7 +55,7 @@ public class ApplicationResource {
return out; return out;
} }
for (final UserLinkApplication app : links) { for (final UserLinkApplication app : links) {
out.add(app.application_id); out.add(app.applicationId);
} }
return out; return out;
} }
@ -64,9 +64,8 @@ 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 = DataAccess.getsWhere(UserLinkApplication.class, new QueryCondition("application_id", "=", applicationId)); links = DataAccess.getsWhere(UserLinkApplication.class, new QueryCondition("object2id", "=", applicationId));
} catch (final Exception e) { } catch (final Exception e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
final String result = "SERVER Internal error"; final String result = "SERVER Internal error";
this.logger.error(" result: {}", result); this.logger.error(" result: {}", result);
@ -74,13 +73,13 @@ public class ApplicationResource {
} }
this.logger.debug("Find list of user for an application: {}", links); this.logger.debug("Find list of user for an application: {}", links);
for (final UserLinkApplication app : links) { for (final UserLinkApplication app : links) {
out.add(app.user_id); out.add(app.userId);
} }
return out; return out;
} }
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// //
// Generic /application/ // Generic /application/
// //
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -124,7 +123,7 @@ public class ApplicationResource {
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// //
// Generic /application/{id} // Generic /application/{id}
// //
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -154,7 +153,7 @@ public class ApplicationResource {
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// //
// Generic /{id}/* // Generic /{id}/*
// //
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -170,7 +169,7 @@ public class ApplicationResource {
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
// //
// Generic /application/* // Generic /application/*
// //
//////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////
@ -263,7 +262,7 @@ public class ApplicationResource {
UserLinkApplication links = null; UserLinkApplication links = null;
try { try {
links = DataAccess.getWhere(UserLinkApplication.class, links = DataAccess.getWhere(UserLinkApplication.class,
new QueryAnd(new QueryCondition("user_id", "=", gc.userByToken.id), new QueryCondition("deleted", "=", 0), new QueryCondition("application_id", "=", appl.id))); new QueryAnd(new QueryCondition("userId", "=", gc.userByToken.id), new QueryCondition("deleted", "=", 0), new QueryCondition("object2id", "=", appl.id)));
} catch (final Exception e) { } catch (final Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@ -283,10 +282,12 @@ public class ApplicationResource {
applicationRight.put("USER", true); applicationRight.put("USER", true);
} }
final Map<String, Object> outRight = new HashMap<>(); final Map<String, Object> outRight = new HashMap<>();
// we set the right in the under map to manage multiple application group right. and in some application user can see other user or all user of the application // we set the right in the under map to manage multiple application group right.
// and in some application user can see other user or all user of the
// application
outRight.put(applicationName, applicationRight); outRight.put(applicationName, applicationRight);
final String ret = JWTWrapper.generateJWToken(gc.userByToken.id, gc.userByToken.name, "KarAuth", applicationName, outRight, -appl.ttl); final String ret = JWTWrapper.generateJWToken(gc.userByToken.id, gc.userByToken.name, "KarAuth", applicationName, outRight, -appl.ttl);
//logger.debug(" ==> generate token: {}", ret); // logger.debug(" ==> generate token: {}", ret);
String returnAdress = appl.redirect; String returnAdress = appl.redirect;
if (isDev) { if (isDev) {
returnAdress = appl.redirectDev; returnAdress = appl.redirectDev;

View File

@ -15,6 +15,7 @@ import org.kar.archidata.model.GenericDataSoftDelete;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import jakarta.persistence.Column;
import jakarta.persistence.Table; import jakarta.persistence.Table;
// TODO: remove this, it must be generated instead of manually create /// // TODO: remove this, it must be generated instead of manually create ///
@ -22,6 +23,8 @@ import jakarta.persistence.Table;
@DataIfNotExists @DataIfNotExists
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class UserLinkApplication extends GenericDataSoftDelete { public class UserLinkApplication extends GenericDataSoftDelete {
public Long user_id; @Column(name = "object1id")
public Long application_id; public Long userId;
@Column(name = "object2id")
public Long applicationId;
} }

View File

@ -1,13 +1,13 @@
{ {
"name": "karideo", "name": "karso",
"version": "0.0.0", "version": "0.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "karideo", "name": "karso",
"version": "0.0.0", "version": "0.0.0",
"license": "MIT", "license": "MPL-2",
"dependencies": { "dependencies": {
"@angular/animations": "^14.2.10", "@angular/animations": "^14.2.10",
"@angular/cdk": "^14.2.7", "@angular/cdk": "^14.2.7",