Skip to content

Commit

Permalink
RANGER-4933: Ranger API to Summary View of DataShares in GDS
Browse files Browse the repository at this point in the history
Signed-off-by: Ramesh Mani <[email protected]>
  • Loading branch information
rkundam authored and Ramesh Mani committed Oct 25, 2024
1 parent 9268778 commit 8038af6
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public static class RangerDataset extends RangerGdsBaseModelObject implements ja
private RangerGdsObjectACL acl;
private RangerValiditySchedule validitySchedule;
private String termsOfUse;
private List<String> labels;
private List<String> keywords;

public RangerDataset() { }

Expand All @@ -112,6 +114,22 @@ public RangerDataset() { }

public void setTermsOfUse(String termsOfUse) { this.termsOfUse = termsOfUse; }

public List<String> getLabels() {
return labels;
}

public void setLabels(List<String> labels) {
this.labels = labels;
}

public List<String> getKeywords() {
return keywords;
}

public void setKeywords(List<String> keywords) {
this.keywords = keywords;
}

@Override
public StringBuilder toString(StringBuilder sb) {
sb.append("RangerDataset={");
Expand All @@ -122,6 +140,8 @@ public StringBuilder toString(StringBuilder sb) {
.append("acl={").append(acl).append("} ")
.append("validitySchedule={").append(validitySchedule).append("} ")
.append("termsOfUse={").append(termsOfUse).append("} ")
.append("labels={").append(validitySchedule).append("} ")
.append("keywords={").append(termsOfUse).append("} ")
.append("}");

return sb;
Expand Down Expand Up @@ -568,6 +588,9 @@ public static class DatasetSummary extends RangerBaseModelObject implements java
private Long projectsCount;
private Long totalResourceCount;
private List<DataShareInDatasetSummary> dataShares;
private RangerValiditySchedule validitySchedule;
private List<String> labels;
private List<String> keywords;

public DatasetSummary() {
super();
Expand Down Expand Up @@ -631,6 +654,30 @@ public void setAclPrincipalsCount(Map<PrincipalType, Integer> aclPrincipalsCount
this.aclPrincipalsCount = aclPrincipalsCount;
}

public RangerValiditySchedule getValiditySchedule() {
return validitySchedule;
}

public void setValiditySchedule(RangerValiditySchedule validitySchedule) {
this.validitySchedule = validitySchedule;
}

public List<String> getLabels() {
return labels;
}

public void setLabels(List<String> labels) {
this.labels = labels;
}

public List<String> getKeywords() {
return keywords;
}

public void setKeywords(List<String> keywords) {
this.keywords = keywords;
}

@Override
public String toString() {
return toString(new StringBuilder()).toString();
Expand All @@ -649,6 +696,9 @@ public StringBuilder toString(StringBuilder sb) {
.append("aclPrincipalsCount={").append(aclPrincipalsCount).append("} ")
.append("totalResourceCount={").append(totalResourceCount).append("} ")
.append("dataShares={").append(dataShares).append("} ")
.append("validitySchedule={").append(totalResourceCount).append("} ")
.append("labels={").append(totalResourceCount).append("} ")
.append("keywords={").append(totalResourceCount).append("} ")
.append("}");

return sb;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public class SearchFilter {
public static final String DATASET_NAME = "datasetName"; // search, sort
public static final String DATASET_NAME_PARTIAL = "datasetNamePartial"; // search, sort
public static final String DATASET_ID = "datasetId"; // search, sort
public static final String DATASET_LABEL = "datasetLabel";
public static final String DATASET_KEYWORD = "datasetKeyword";
public static final String PROJECT_NAME = "projectName"; // search, sort
public static final String PROJECT_NAME_PARTIAL = "projectNamePartial"; // search, sort
public static final String PROJECT_ID = "projectId"; // search, sort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2042,6 +2042,7 @@ INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('072',UTC_TIMESTAMP(),'Ranger 3.0.0',UTC_TIMESTAMP(),'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('073',UTC_TIMESTAMP(),'Ranger 3.0.0',UTC_TIMESTAMP(),'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('074',UTC_TIMESTAMP(),'Ranger 3.0.0',UTC_TIMESTAMP(),'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('075',UTC_TIMESTAMP(),'Ranger 3.0.0',UTC_TIMESTAMP(),'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y');

INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('J10001',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements. See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
-- The ASF licenses this file to You under the Apache License, Version 2.0
-- (the "License"); you may not use this file except in compliance with
-- the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

drop procedure if exists add_validity_schedule_labels_keywords_in_x_gds_dataset();

delimiter ;;
create procedure add_validity_schedule_labels_keywords_in_x_gds_dataset() begin

if not exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_gds_dataset' and column_name='validity_schedule') then
ALTER TABLE x_gds_dataset ADD validity_schedule TEXT NULL DEFAULT NULL;
end if;

if not exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_gds_dataset' and column_name='labels') then
ALTER TABLE x_gds_dataset ADD labels TEXT NULL DEFAULT NULL;
end if;

if not exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_gds_dataset' and column_name='keywords') then
ALTER TABLE x_gds_dataset ADD keywords TEXT NULL DEFAULT NULL;
end if;

end;;

delimiter ;

call add_validity_schedule_labels_keywords_in_x_gds_dataset();
Original file line number Diff line number Diff line change
Expand Up @@ -1989,6 +1989,7 @@ INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,act
INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '066',sys_extract_utc(systimestamp),'Ranger 3.0.0',sys_extract_utc(systimestamp),'localhost','Y');
INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '073',sys_extract_utc(systimestamp),'Ranger 3.0.0',sys_extract_utc(systimestamp),'localhost','Y');
INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '074',sys_extract_utc(systimestamp),'Ranger 3.0.0',sys_extract_utc(systimestamp),'localhost','Y');
INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '075',sys_extract_utc(systimestamp),'Ranger 3.0.0',sys_extract_utc(systimestamp),'localhost','Y');
INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, 'DB_PATCHES',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y');

INSERT INTO x_user_module_perm (id,user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (X_USER_MODULE_PERM_SEQ.nextval,getXportalUIdByLoginId('admin'),getModulesIdByName('Reports'),sys_extract_utc(systimestamp),sys_extract_utc(systimestamp),getXportalUIdByLoginId('admin'),getXportalUIdByLoginId('admin'),1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements. See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
-- The ASF licenses this file to You under the Apache License, Version 2.0
-- (the "License"); you may not use this file except in compliance with
-- the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

DECLARE
v_count number:=0;
BEGIN
select count(*) into v_count from user_tab_cols where table_name='X_GDS_DATASET' and column_name='VALIDITY_SCHEDULE';
if (v_count = 0) then
execute immediate 'ALTER TABLE x_gds_dataset ADD validity_schedule CLOB DEFAULT NULL NULL';
end if;

select count(*) into v_count from user_tab_cols where table_name='X_GDS_DATASET' and column_name='LABELS';
if (v_count = 0) then
execute immediate 'ALTER TABLE x_gds_dataset ADD labels CLOB DEFAULT NULL NULL';
end if;

select count(*) into v_count from user_tab_cols where table_name='X_GDS_DATASET' and column_name='KEYWORDS';
if (v_count = 0) then
execute immediate 'ALTER TABLE x_gds_dataset ADD keywords CLOB DEFAULT NULL NULL';
end if;
commit;
END;/
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,7 @@ INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('072',current_timestamp,'Ranger 3.0.0',current_timestamp,'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('073',current_timestamp,'Ranger 3.0.0',current_timestamp,'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('074',current_timestamp,'Ranger 3.0.0',current_timestamp,'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('075',current_timestamp,'Ranger 3.0.0',current_timestamp,'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',current_timestamp,'Ranger 1.0.0',current_timestamp,'localhost','Y');

INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements. See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
-- The ASF licenses this file to You under the Apache License, Version 2.0
-- (the "License"); you may not use this file except in compliance with
-- the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

select 'delimiter start';
CREATE OR REPLACE FUNCTION add_validity_schedule_labels_keywords_in_x_gds_dataset()
RETURNS void AS $$
DECLARE
v_column_exists integer := 0;
BEGIN
select count(*) into v_column_exists from pg_attribute where attrelid in(select oid from pg_class where relname='x_gds_dataset') and attname='validity_schedule';
IF v_column_exists = 0 THEN
ALTER TABLE x_gds_dataset ADD COLUMN validity_schedule TEXT DEFAULT NULL NULL;
END IF;

select count(*) into v_column_exists from pg_attribute where attrelid in(select oid from pg_class where relname='x_gds_dataset') and attname='labels';
IF v_column_exists = 0 THEN
ALTER TABLE x_gds_dataset ADD COLUMN labels TEXT DEFAULT NULL NULL;
END IF;

select count(*) into v_column_exists from pg_attribute where attrelid in(select oid from pg_class where relname='x_gds_dataset') and attname='keywords';
IF v_column_exists = 0 THEN
ALTER TABLE x_gds_dataset ADD COLUMN keywords TEXT DEFAULT NULL NULL;
END IF;
END;
$$ LANGUAGE plpgsql;
select 'delimiter end';

select add_validity_schedule_labels_keywords_in_x_gds_dataset();
select 'delimiter end';
commit;
Original file line number Diff line number Diff line change
Expand Up @@ -2288,6 +2288,8 @@ INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active
GO
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('074',CURRENT_TIMESTAMP,'Ranger 3.0.0',CURRENT_TIMESTAMP,'localhost','Y');
GO
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('075',CURRENT_TIMESTAMP,'Ranger 3.0.0',CURRENT_TIMESTAMP,'localhost','Y');
GO
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y');
GO
INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (dbo.getXportalUIdByLoginId('admin'),dbo.getModulesIdByName('Reports'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,dbo.getXportalUIdByLoginId('admin'),dbo.getXportalUIdByLoginId('admin'),1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements. See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
-- The ASF licenses this file to You under the Apache License, Version 2.0
-- (the "License"); you may not use this file except in compliance with
-- the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

IF NOT EXISTS(select * from SYS.SYSCOLUMNS where tname = 'x_gds_dataset' and cname = 'validity_schedule') THEN
ALTER TABLE dbo.x_gds_dataset ADD validity_schedule TEXT DEFAULT NULL NULL;
END IF;
GO
IF NOT EXISTS(select * from SYS.SYSCOLUMNS where tname = 'x_gds_dataset' and cname = 'labels') THEN
ALTER TABLE dbo.x_gds_dataset ADD labels TEXT DEFAULT NULL NULL;
END IF;
GO
IF NOT EXISTS(select * from SYS.SYSCOLUMNS where tname = 'x_gds_dataset' and cname = 'keywords') THEN
ALTER TABLE dbo.x_gds_dataset ADD keywords TEXT DEFAULT NULL NULL;
END IF;
GO
exit
Original file line number Diff line number Diff line change
Expand Up @@ -4145,6 +4145,7 @@ INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('066',CURRENT_TIMESTAMP,'Ranger 3.0.0',CURRENT_TIMESTAMP,'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('073',CURRENT_TIMESTAMP,'Ranger 3.0.0',CURRENT_TIMESTAMP,'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('074',CURRENT_TIMESTAMP,'Ranger 3.0.0',CURRENT_TIMESTAMP,'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('075',CURRENT_TIMESTAMP,'Ranger 3.0.0',CURRENT_TIMESTAMP,'localhost','Y');
INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y');
INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (dbo.getXportalUIdByLoginId('admin'),dbo.getModulesIdByName('Reports'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,dbo.getXportalUIdByLoginId('admin'),dbo.getXportalUIdByLoginId('admin'),1);
INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (dbo.getXportalUIdByLoginId('admin'),dbo.getModulesIdByName('Resource Based Policies'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,dbo.getXportalUIdByLoginId('admin'),dbo.getXportalUIdByLoginId('admin'),1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements. See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
-- The ASF licenses this file to You under the Apache License, Version 2.0
-- (the "License"); you may not use this file except in compliance with
-- the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

GO
IF NOT EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = 'x_gds_dataset' and column_name = 'validity_schedule')
BEGIN
ALTER TABLE [dbo].[x_gds_dataset] ADD [validity_schedule] [nvarchar](max) DEFAULT NULL NULL;
END
GO
GO
IF NOT EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = 'x_gds_dataset' and column_name = 'labels')
BEGIN
ALTER TABLE [dbo].[x_gds_dataset] ADD [labels] [nvarchar](max) DEFAULT NULL NULL;
END
GO
GO
IF NOT EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = 'x_gds_dataset' and column_name = 'keywords')
BEGIN
ALTER TABLE [dbo].[x_gds_dataset] ADD [keywords] [nvarchar](max) DEFAULT NULL NULL;
END
GO
exit
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,9 @@ private List<DatasetSummary> toDatasetSummary(List<RangerDataset> datasets, GdsP
datasetSummary.setGuid(dataset.getGuid());
datasetSummary.setVersion(dataset.getVersion());
datasetSummary.setPermissionForCaller(permissionForCaller);
datasetSummary.setValiditySchedule(dataset.getValiditySchedule());
datasetSummary.setLabels(dataset.getLabels());
datasetSummary.setKeywords(dataset.getKeywords());

ret.add(datasetSummary);

Expand Down
Loading

0 comments on commit 8038af6

Please sign in to comment.