@@ -1868,7 +1868,8 @@ geoflow_entity <- R6Class("geoflow_entity",
1868
1868
# '@description Enrichs the entity with subjects. If no subject specify in Subjects,
1869
1869
# 'automatically add keyword from dictionary to 'theme' category
1870
1870
# '@param config geoflow config object
1871
- enrichWithSubjects = function (config ){
1871
+ # '@param exclusions exclusions
1872
+ enrichWithSubjects = function (config , exclusions = c()){
1872
1873
1873
1874
data_objects <- self $ data
1874
1875
if (is(data_objects , " geoflow_data" )) data_objects <- list (self $ data )
@@ -1880,51 +1881,54 @@ geoflow_entity <- R6Class("geoflow_entity",
1880
1881
# List all columns of data features
1881
1882
columns <- colnames(data_object $ features )
1882
1883
for (featureAttrName in columns ){
1883
- # Check if correspond column exist in dictionary
1884
- fat_attr <- NULL
1885
- fto <- data_object $ featureTypeObj
1886
- if (! is.null(fto )) fat_attr <- fto $ getMemberById(featureAttrName )
1887
- if (! is.null(fat_attr )){
1888
- # Check if register is link
1889
- registerId <- fat_attr $ registerId
1890
-
1891
- if (! is.null(registerId )) if (! is.na(registerId )){
1892
- registers <- config $ registers
1893
- if (length(registers )> 0 ) {
1894
- registers <- registers [sapply(registers , function (x ){x $ id == registerId })]
1895
- fat_attr_register <- registers [[1 ]]
1896
-
1897
- # Check if values of column are in register
1898
- dataAttrValues <- unique(data_object $ features [featureAttrName ])
1899
- featureAttrValues <- switch (class(data_object $ features )[1 ],
1900
- " sf" = data_object $ features [,featureAttrName ][[1 ]],
1901
- " data.frame" = data_object $ features [,featureAttrName ]
1902
- )
1903
- featureAttrValues <- unique(featureAttrValues )
1904
- matchAttrValues <- subset(fat_attr_register $ data , code %in% featureAttrValues )
1905
-
1906
- if (nrow(matchAttrValues )> 0 ){
1907
- defSource <- fat_attr $ defSource
1908
- if (is.na(defSource )){desc_name <- paste0(" [" ,fat_attr $ name ," ]" )}else {
1909
- desc_name <- paste0(" [" ,defSource [1 ]," ]" )
1910
- if (! is.null(attr(defSource ," description" ))) desc_name <- paste0(" [" ,attr(defSource ," description" )," ]" )
1911
- if (! is.null(attr(defSource ," uri" ))) desc_name <- paste0(desc_name ," @" ,attr(defSource ," uri" ))
1912
- }
1913
- subject_obj <- geoflow_subject $ new()
1914
- subject_obj $ setKey(" theme" )
1915
- subject_obj $ setName(desc_name )
1916
- for (i in 1 : nrow(matchAttrValues )){
1917
- subject_obj $ addKeyword(
1918
- keyword = paste0(matchAttrValues $ label [i ]," [" ,matchAttrValues $ code [i ]," ]" ),
1919
- uri = if (! is.na(matchAttrValues $ uri [i ])) matchAttrValues $ uri [i ] else NULL
1920
- )
1921
- }
1922
- self $ addSubject(subject_obj )
1923
-
1924
- }
1925
- }
1926
- }
1927
- }
1884
+
1885
+ if (featureAttrName %in% exclusions ) next
1886
+
1887
+ # Check if correspond column exist in dictionary
1888
+ fat_attr <- NULL
1889
+ fto <- data_object $ featureTypeObj
1890
+ if (! is.null(fto )) fat_attr <- fto $ getMemberById(featureAttrName )
1891
+ if (! is.null(fat_attr )){
1892
+ # Check if register is link
1893
+ registerId <- fat_attr $ registerId
1894
+
1895
+ if (! is.null(registerId )) if (! is.na(registerId )){
1896
+ registers <- config $ registers
1897
+ if (length(registers )> 0 ) {
1898
+ registers <- registers [sapply(registers , function (x ){x $ id == registerId })]
1899
+ fat_attr_register <- registers [[1 ]]
1900
+
1901
+ # Check if values of column are in register
1902
+ dataAttrValues <- unique(data_object $ features [featureAttrName ])
1903
+ featureAttrValues <- switch (class(data_object $ features )[1 ],
1904
+ " sf" = data_object $ features [,featureAttrName ][[1 ]],
1905
+ " data.frame" = data_object $ features [,featureAttrName ]
1906
+ )
1907
+ featureAttrValues <- unique(featureAttrValues )
1908
+ matchAttrValues <- subset(fat_attr_register $ data , code %in% featureAttrValues )
1909
+
1910
+ if (nrow(matchAttrValues )> 0 ){
1911
+ defSource <- fat_attr $ defSource
1912
+ if (is.na(defSource )){desc_name <- paste0(" [" ,fat_attr $ name ," ]" )}else {
1913
+ desc_name <- paste0(" [" ,defSource [1 ]," ]" )
1914
+ if (! is.null(attr(defSource ," description" ))) desc_name <- paste0(" [" ,attr(defSource ," description" )," ]" )
1915
+ if (! is.null(attr(defSource ," uri" ))) desc_name <- paste0(desc_name ," @" ,attr(defSource ," uri" ))
1916
+ }
1917
+ subject_obj <- geoflow_subject $ new()
1918
+ subject_obj $ setKey(" theme" )
1919
+ subject_obj $ setName(desc_name )
1920
+ for (i in 1 : nrow(matchAttrValues )){
1921
+ subject_obj $ addKeyword(
1922
+ keyword = paste0(matchAttrValues $ label [i ]," [" ,matchAttrValues $ code [i ]," ]" ),
1923
+ uri = if (! is.na(matchAttrValues $ uri [i ])) matchAttrValues $ uri [i ] else NULL
1924
+ )
1925
+ }
1926
+ self $ addSubject(subject_obj )
1927
+
1928
+ }
1929
+ }
1930
+ }
1931
+ }
1928
1932
}
1929
1933
}
1930
1934
0 commit comments