Skip to content

Commit

Permalink
Cleanup repo
Browse files Browse the repository at this point in the history
  • Loading branch information
tchrapovic committed Aug 28, 2023
1 parent bfb35a9 commit 9d762b5
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 196 deletions.
15 changes: 2 additions & 13 deletions config/sql/native-new/postgres-new.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1171,12 +1171,7 @@ CREATE TABLE m_role_analysis_cluster_table (
CHECK (objectType = 'ROLE_ANALYSIS_CLUSTER'),
parentRefTargetOid UUID,
parentRefTargetType ObjectType,
parentRefRelationId INTEGER REFERENCES m_uri(id),
usersCount INTEGER,
rolesCount INTEGER,
membershipDensity DECIMAL,
membershipMean DECIMAL,
detectedReductionMetric DECIMAL
parentRefRelationId INTEGER REFERENCES m_uri(id)
)
INHERITS (m_assignment_holder);

Expand All @@ -1197,13 +1192,7 @@ CREATE TYPE RoleAnalysisProcessModeType AS ENUM ('ROLE', 'USER');
CREATE TABLE m_role_analysis_session_table (
oid UUID NOT NULL PRIMARY KEY REFERENCES m_object_oid(oid),
objectType ObjectType GENERATED ALWAYS AS ('ROLE_ANALYSIS_SESSION') STORED
CHECK (objectType = 'ROLE_ANALYSIS_SESSION'),
-- processedObjectCount INTEGER,
-- clusterCount INTEGER,
-- clustersMeanDensity DECIMAL,
similarityOption DECIMAL,
minMembersOption INTEGER,
overlapOption INTEGER
CHECK (objectType = 'ROLE_ANALYSIS_SESSION')
)
INHERITS (m_assignment_holder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@

public class MClusterObject extends MObject {

//TODO change long to decimal

public String riskLevel;
public Integer usersCount;
public Integer rolesCount;

public Long membershipDensity;
public Long detectedReductionMetric;
public Long membershipMean;

public UUID parentRefTargetOid;
public MObjectType parentRefTargetType;
public Integer parentRefRelationId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,6 @@ public class QClusterData extends QAssignmentHolder<MClusterObject> {

public static final String TABLE_NAME = "m_role_analysis_cluster_table";

public static final ColumnMetadata USERS_COUNT =
ColumnMetadata.named("usersCount").ofType(Types.INTEGER);

public final NumberPath<Integer> usersCount =
createInteger("usersCount", USERS_COUNT);

public static final ColumnMetadata ROLES_COUNT =
ColumnMetadata.named("rolesCount").ofType(Types.INTEGER);

public final NumberPath<Integer> rolesCount =
createInteger("rolesCount", ROLES_COUNT);

public static final ColumnMetadata DENSITY =
ColumnMetadata.named("membershipDensity").ofType(Types.LONGNVARCHAR);

public final NumberPath<Long> membershipDensity =
createLong("membershipDensity", DENSITY);

public static final ColumnMetadata MEAN =
ColumnMetadata.named("membershipMean").ofType(Types.LONGNVARCHAR);

public final NumberPath<Long> membershipMean =
createLong("membershipMean", MEAN);

public static final ColumnMetadata DETECTED_REDUCTION_PATTERN =
ColumnMetadata.named("detectedReductionMetric").ofType(Types.LONGNVARCHAR);

public final NumberPath<Long> detectedReductionMetric =
createLong("detectedReductionMetric", DETECTED_REDUCTION_PATTERN);

public static final ColumnMetadata PARENT_REF_TARGET_OID =
ColumnMetadata.named("parentRefTargetOid").ofType(UuidPath.UUID_TYPE);

Expand All @@ -72,10 +42,6 @@ public class QClusterData extends QAssignmentHolder<MClusterObject> {
public final NumberPath<Integer> parentRefRelationId =
createInteger("parentRefRelationId", PARENT_REF_TARGET_RELATION);

public static final ColumnMetadata RISK_LEVEL =
ColumnMetadata.named("riskLevel").ofType(Types.VARCHAR);
public final StringPath riskLevel = createString("riskLevel", RISK_LEVEL);

public QClusterData(String variable) {
this(variable, DEFAULT_SCHEMA_NAME, TABLE_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class QClusterObjectMapping
extends QAssignmentHolderMapping<RoleAnalysisClusterType, QClusterData, MClusterObject> {

public static final String DEFAULT_ALIAS_NAME = "roleAnalysisCluster";
private static final int DEFAULT_DECIMALS = 1000;

public static QClusterObjectMapping init(@NotNull SqaleRepoContext repositoryContext) {
return new QClusterObjectMapping(repositoryContext);
Expand All @@ -39,18 +38,6 @@ private QClusterObjectMapping(@NotNull SqaleRepoContext repositoryContext) {
q -> q.parentRefRelationId,
QObjectMapping::getObjectMapping);

addNestedMapping(F_CLUSTER_STATISTICS, AnalysisClusterStatisticType.class)
.addItemMapping(F_DETECTED_REDUCTION_METRIC,
longMapper(q -> q.detectedReductionMetric))
.addItemMapping(AnalysisClusterStatisticType.F_MEMBERSHIP_DENSITY,
longMapper(q -> q.membershipDensity))
.addItemMapping(AnalysisClusterStatisticType.F_MEMBERSHIP_MEAN,
longMapper(q -> q.membershipMean))
.addItemMapping(AnalysisClusterStatisticType.F_USERS_COUNT,
integerMapper(q -> q.usersCount))
.addItemMapping(AnalysisClusterStatisticType.F_ROLES_COUNT,
integerMapper(q -> q.rolesCount));

}

@Override
Expand All @@ -73,19 +60,6 @@ public MClusterObject newRowObject() {
t -> row.parentRefTargetType = t,
r -> row.parentRefRelationId = r);

AnalysisClusterStatisticType clusterStatistics = clusterObject.getClusterStatistics();
if (clusterStatistics != null) {
row.membershipMean = (long) (clusterStatistics.getMembershipMean() * DEFAULT_DECIMALS);
row.membershipDensity = (long) (clusterStatistics.getMembershipDensity() * DEFAULT_DECIMALS);
row.detectedReductionMetric = (long) (clusterStatistics.getDetectedReductionMetric() * DEFAULT_DECIMALS);

row.usersCount = clusterObject.getClusterStatistics().getUsersCount();
row.rolesCount = clusterObject.getClusterStatistics().getRolesCount();

row.riskLevel = clusterStatistics.getRiskLevel();

}

return row;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,4 @@

public class MSessionObject extends MObject {

//TODO change long to decimal and add processMode?.
public String riskLevel;

public RoleAnalysisProcessModeType processMode;

public Long clustersMeanDensity;
public Integer clusterCount;
public Integer processedObjectCount;

public Long similarityOption;
public Integer minMembersOption;
public Integer overlapOption;

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,59 +26,6 @@ public class QSessionData extends QAssignmentHolder<MSessionObject> {

public static final String TABLE_NAME = "m_role_analysis_session_table";

public static final ColumnMetadata SIMILARITY =
ColumnMetadata.named("similarityOption").ofType(Types.LONGNVARCHAR);

public final NumberPath<Long> similarityOption =
createLong("similarityOption", SIMILARITY);

public static final ColumnMetadata MIN_CLUSTER_MEMBERS =
ColumnMetadata.named("minMembersOption").ofType(Types.INTEGER);

public final NumberPath<Integer> minMembersOption =
createInteger("minMembersOption", MIN_CLUSTER_MEMBERS);

public static final ColumnMetadata OVERLAP_OPTION =
ColumnMetadata.named("overlapOption").ofType(Types.INTEGER);

public final NumberPath<Integer> overlapOption =
createInteger("overlapOption", OVERLAP_OPTION);

public static final ColumnMetadata PROCESSED_OBJECTS =
ColumnMetadata.named("processedObjectCount").ofType(Types.INTEGER);

public final NumberPath<Integer> processedObjectCount =
createInteger("processedObjectCount", PROCESSED_OBJECTS);

public static final ColumnMetadata MEAN_DENSITY =
ColumnMetadata.named("clustersMeanDensity").ofType(Types.LONGNVARCHAR);

public final NumberPath<Long> clustersMeanDensity =
createLong("clustersMeanDensity", MEAN_DENSITY);

public static final ColumnMetadata CLUSTER_COUNT =
ColumnMetadata.named("clusterCount").ofType(Types.INTEGER);

public final NumberPath<Integer> clusterCount =
createInteger("clusterCount", CLUSTER_COUNT);

public static final ColumnMetadata ROLE_ANALYSIS_CLUSTERS_REF =
ColumnMetadata.named("roleAnalysisClusterRef").ofType(Types.ARRAY);

public final ArrayPath<String[], String> roleAnalysisClusterRef = createArray("roleAnalysisClusterRef",
String[].class, ROLE_ANALYSIS_CLUSTERS_REF);

public static final ColumnMetadata RISK_LEVEL =
ColumnMetadata.named("riskLevel").ofType(Types.VARCHAR);

public final StringPath riskLevel = createString("riskLevel", RISK_LEVEL);

public static final ColumnMetadata PROCESS_MODE =
ColumnMetadata.named("processMode").ofType(Types.OTHER);

public final EnumPath<RoleAnalysisProcessModeType> processMode =
createEnum("processMode", RoleAnalysisProcessModeType.class, PROCESS_MODE);

public QSessionData(String variable) {
this(variable, DEFAULT_SCHEMA_NAME, TABLE_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public class QSessionObjectMapping
extends QAssignmentHolderMapping<RoleAnalysisSessionType, QSessionData, MSessionObject> {

public static final String DEFAULT_ALIAS_NAME = "roleAnalysisSession";
private static final int DEFAULT_DECIMALS = 1000;

public static QSessionObjectMapping init(@NotNull SqaleRepoContext repositoryContext) {
return new QSessionObjectMapping(repositoryContext);
Expand All @@ -30,30 +29,6 @@ private QSessionObjectMapping(@NotNull SqaleRepoContext repositoryContext) {
super(QSessionData.TABLE_NAME, DEFAULT_ALIAS_NAME,
RoleAnalysisSessionType.class, QSessionData.class, repositoryContext);

// addNestedMapping(F_SESSION_STATISTIC, RoleAnalysisSessionStatisticType.class)
// .addItemMapping(RoleAnalysisSessionStatisticType.F_PROCESSED_OBJECT_COUNT,
// integerMapper(q -> q.processedObjectCount))
// .addItemMapping(RoleAnalysisSessionStatisticType.F_CLUSTER_COUNT,
// integerMapper(q -> q.clusterCount))
// .addItemMapping(RoleAnalysisSessionStatisticType.F_MEAN_DENSITY,
// longMapper(q -> q.clustersMeanDensity));

addNestedMapping(F_USER_MODE_OPTIONS, AbstractAnalysisSessionOptionType.class)
.addItemMapping(AbstractAnalysisSessionOptionType.F_SIMILARITY_THRESHOLD,
longMapper(q -> q.similarityOption))
.addItemMapping(AbstractAnalysisSessionOptionType.F_MIN_MEMBERS_COUNT,
integerMapper(q -> q.minMembersOption))
.addItemMapping(AbstractAnalysisSessionOptionType.F_MIN_PROPERTIES_OVERLAP,
integerMapper(q -> q.overlapOption));

addNestedMapping(F_ROLE_MODE_OPTIONS, AbstractAnalysisSessionOptionType.class)
.addItemMapping(AbstractAnalysisSessionOptionType.F_SIMILARITY_THRESHOLD,
longMapper(q -> q.similarityOption))
.addItemMapping(AbstractAnalysisSessionOptionType.F_MIN_MEMBERS_COUNT,
integerMapper(q -> q.minMembersOption))
.addItemMapping(AbstractAnalysisSessionOptionType.F_MIN_PROPERTIES_OVERLAP,
integerMapper(q -> q.overlapOption));

}

@Override
Expand All @@ -69,28 +44,7 @@ public MSessionObject newRowObject() {
@Override
public @NotNull MSessionObject toRowObjectWithoutFullObject(
RoleAnalysisSessionType session, JdbcSession jdbcSession) {
MSessionObject row = super.toRowObjectWithoutFullObject(session, jdbcSession);

RoleAnalysisSessionOptionType roleModeOptions = session.getRoleModeOptions();
UserAnalysisSessionOptionType userModeOptions = session.getUserModeOptions();
if (roleModeOptions != null) {
row.similarityOption = (long) (roleModeOptions.getSimilarityThreshold() * DEFAULT_DECIMALS);
row.minMembersOption = roleModeOptions.getMinMembersCount();
row.overlapOption = roleModeOptions.getMinPropertiesOverlap();
} else if (userModeOptions != null) {
row.similarityOption = (long) (userModeOptions.getSimilarityThreshold() * DEFAULT_DECIMALS);
row.minMembersOption = userModeOptions.getMinMembersCount();
row.overlapOption = userModeOptions.getMinPropertiesOverlap();
}


// if (session.getSessionStatistic() != null) {
// RoleAnalysisSessionStatisticType sessionStatistic = session.getSessionStatistic();
// row.clustersMeanDensity = (long) (sessionStatistic.getMeanDensity() * DEFAULT_DECIMALS);
// row.clusterCount = sessionStatistic.getClusterCount();
// row.processedObjectCount = sessionStatistic.getProcessedObjectCount();
// }

return row;
return super.toRowObjectWithoutFullObject(session, jdbcSession);
}
}

0 comments on commit 9d762b5

Please sign in to comment.