forked from avniproject/avni-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Got rid of code smell,primitive obsession,followed DRY
- Loading branch information
1 parent
29eebe5
commit 6f304c4
Showing
16 changed files
with
337 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
avni-server-api/src/main/java/org/avni/server/domain/metabase/Collection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.avni.server.domain.metabase; | ||
|
||
public class Collection { | ||
private String name; | ||
private String description; | ||
|
||
public Collection(String name, String description) { | ||
this.name = name; | ||
this.description = description; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
avni-server-api/src/main/java/org/avni/server/domain/metabase/CollectionPermissions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.avni.server.domain.metabase; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class CollectionPermissions { | ||
private Map<String, Object> permissionsGraph; | ||
|
||
public CollectionPermissions(Map<String, Object> permissionsGraph) { | ||
this.permissionsGraph = permissionsGraph; | ||
} | ||
|
||
public Map<String, Object> getPermissionsGraph() { | ||
return permissionsGraph; | ||
} | ||
|
||
public void updatePermissionsGraph(int groupId, int collectionId) { | ||
Map<String, Map<String, String>> groups = (Map<String, Map<String, String>>) permissionsGraph.get("groups"); | ||
|
||
groups.computeIfAbsent(String.valueOf(groupId), k -> new HashMap<>()); | ||
Map<String, String> groupPermissions = groups.get(String.valueOf(groupId)); | ||
groupPermissions.put(String.valueOf(collectionId), "write"); | ||
|
||
if (groups.containsKey("1")) { | ||
Map<String, String> allGroupPermissions = groups.get("1"); | ||
allGroupPermissions.put(String.valueOf(collectionId), "none"); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
avni-server-api/src/main/java/org/avni/server/domain/metabase/CollectionResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.avni.server.domain.metabase; | ||
|
||
public class CollectionResponse { | ||
private int id; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
avni-server-api/src/main/java/org/avni/server/domain/metabase/Database.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.avni.server.domain.metabase; | ||
|
||
public class Database { | ||
private String name; | ||
private String engine; | ||
private DatabaseDetails details; | ||
|
||
public Database(String name, String engine, DatabaseDetails details) { | ||
this.name = name; | ||
this.engine = engine; | ||
this.details = details; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getEngine() { | ||
return engine; | ||
} | ||
|
||
public DatabaseDetails getDetails() { | ||
return details; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
avni-server-api/src/main/java/org/avni/server/domain/metabase/DatabaseDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.avni.server.domain.metabase; | ||
|
||
public class DatabaseDetails { | ||
private String host; | ||
private String port; | ||
private String db; | ||
private String user; | ||
|
||
public DatabaseDetails(String host, String port, String db, String user) { | ||
this.host = host; | ||
this.port = port; | ||
this.db = db; | ||
this.user = user; | ||
} | ||
|
||
|
||
public String getHost() { | ||
return host; | ||
} | ||
|
||
public String getPort() { | ||
return port; | ||
} | ||
|
||
public String getDb() { | ||
return db; | ||
} | ||
|
||
public String getUser() { | ||
return user; | ||
} | ||
|
||
|
||
} | ||
|
13 changes: 13 additions & 0 deletions
13
avni-server-api/src/main/java/org/avni/server/domain/metabase/DatabaseResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.avni.server.domain.metabase; | ||
|
||
public class DatabaseResponse { | ||
private int id; | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
avni-server-api/src/main/java/org/avni/server/domain/metabase/Group.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.avni.server.domain.metabase; | ||
|
||
public class Group { | ||
private int id; | ||
private boolean hasPermission; | ||
|
||
public Group(int id, boolean hasPermission) { | ||
this.id = id; | ||
this.hasPermission = hasPermission; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public boolean hasPermission() { | ||
return hasPermission; | ||
} | ||
|
||
public void setPermission(boolean hasPermission) { | ||
this.hasPermission = hasPermission; | ||
} | ||
} |
Oops, something went wrong.