Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
Updater
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open-Data
Updater
Commits
e5fecf65
Verified
Commit
e5fecf65
authored
5 months ago
by
Jesper Zedlitz
Browse files
Options
Downloads
Patches
Plain Diff
marked old CKAN stuff
parent
f4569272
Branches
piveau
No related tags found
No related merge requests found
Pipeline
#1685
failed
5 months ago
Stage: build
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/landsh/opendata/OpenDataUpdatesPiveau.java
+26
-11
26 additions, 11 deletions
src/main/java/de/landsh/opendata/OpenDataUpdatesPiveau.java
with
26 additions
and
11 deletions
src/main/java/de/landsh/opendata/OpenDataUpdatesPiveau.java
+
26
−
11
View file @
e5fecf65
...
@@ -34,7 +34,6 @@ import java.time.LocalDate;
...
@@ -34,7 +34,6 @@ import java.time.LocalDate;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
* Bearbeiten von Datenänderungen direkt über das CKAN API.
* Bearbeiten von Datenänderungen direkt über das CKAN API.
...
@@ -58,7 +57,7 @@ public class OpenDataUpdatesPiveau {
...
@@ -58,7 +57,7 @@ public class OpenDataUpdatesPiveau {
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
<
1
||
!
new
File
(
args
[
0
]).
exists
())
{
if
(
args
.
length
<
1
||
!
new
File
(
args
[
0
]).
exists
())
{
System
.
out
.
println
(
"USAGE: java OpenDataUpdates
Ckan
config.yml [single_dataset_id]"
);
System
.
out
.
println
(
"USAGE: java OpenDataUpdates
Piveau
config.yml [single_dataset_id]"
);
System
.
exit
(
2
);
System
.
exit
(
2
);
}
}
...
@@ -96,6 +95,10 @@ public class OpenDataUpdatesPiveau {
...
@@ -96,6 +95,10 @@ public class OpenDataUpdatesPiveau {
}
}
/**
* @deprecated old CKAN stuff
*/
@Deprecated
public
static
String
getExtrasValue
(
JSONObject
dataset
,
String
key
)
{
public
static
String
getExtrasValue
(
JSONObject
dataset
,
String
key
)
{
final
JSONArray
extras
=
dataset
.
getJSONArray
(
"extras"
);
final
JSONArray
extras
=
dataset
.
getJSONArray
(
"extras"
);
for
(
Object
o
:
extras
)
{
for
(
Object
o
:
extras
)
{
...
@@ -125,6 +128,10 @@ public class OpenDataUpdatesPiveau {
...
@@ -125,6 +128,10 @@ public class OpenDataUpdatesPiveau {
return
result
;
return
result
;
}
}
/**
* @deprecated old CKAN stuff
*/
@Deprecated
static
void
removeExtraValue
(
JSONObject
dataset
,
String
key
)
{
static
void
removeExtraValue
(
JSONObject
dataset
,
String
key
)
{
JSONArray
extras
=
dataset
.
getJSONArray
(
"extras"
);
JSONArray
extras
=
dataset
.
getJSONArray
(
"extras"
);
int
foundAtPosition
=
-
1
;
int
foundAtPosition
=
-
1
;
...
@@ -139,6 +146,10 @@ public class OpenDataUpdatesPiveau {
...
@@ -139,6 +146,10 @@ public class OpenDataUpdatesPiveau {
}
}
}
}
/**
* @deprecated old CKAN stuff
*/
@Deprecated
static
void
setExtraValue
(
JSONObject
dataset
,
String
key
,
String
value
)
{
static
void
setExtraValue
(
JSONObject
dataset
,
String
key
,
String
value
)
{
final
JSONObject
entry
=
new
JSONObject
();
final
JSONObject
entry
=
new
JSONObject
();
entry
.
put
(
"key"
,
key
);
entry
.
put
(
"key"
,
key
);
...
@@ -319,14 +330,14 @@ public class OpenDataUpdatesPiveau {
...
@@ -319,14 +330,14 @@ public class OpenDataUpdatesPiveau {
return
false
;
return
false
;
}
}
final
String
newestDatasetId
=
ckanAPI
.
findNewestDataset
(
update
.
collectionId
);
final
Optional
<
String
>
newestDatasetId
=
findNewestDataset
(
update
.
collectionId
);
if
(
newestDatasetId
==
null
)
{
if
(
newestDatasetId
.
isEmpty
()
)
{
log
.
error
(
"In der Collection {} gibt es keinen Datensatz."
,
update
.
collectionId
);
log
.
error
(
"In der Collection {} gibt es keinen Datensatz."
,
update
.
collectionId
);
return
false
;
return
false
;
}
}
final
JSONObject
existingDataset
=
ckanAPI
.
readDataset
(
newestDatasetId
);
final
JSONObject
existingDataset
=
ckanAPI
.
readDataset
(
newestDatasetId
.
get
()
);
log
.
info
(
"Änderung erkannt an Dataset "
+
newestDatasetId
);
log
.
info
(
"Änderung erkannt an Dataset "
+
newestDatasetId
);
final
String
timeNow
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_DATE_TIME
);
final
String
timeNow
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_DATE_TIME
);
final
DatasetMetadata
metadata
=
readMetadata
(
localDataDir
);
final
DatasetMetadata
metadata
=
readMetadata
(
localDataDir
);
...
@@ -418,6 +429,10 @@ public class OpenDataUpdatesPiveau {
...
@@ -418,6 +429,10 @@ public class OpenDataUpdatesPiveau {
}
}
Optional
<
String
>
findNewestDataset
(
String
collectionId
)
throws
IOException
{
return
Optional
.
ofNullable
(
ckanAPI
.
findNewestDataset
(
collectionId
));
}
/**
/**
* Datei wird einfach überschrieben und ist nicht öffentlich erreichbar.
* Datei wird einfach überschrieben und ist nicht öffentlich erreichbar.
* <p>
* <p>
...
@@ -431,14 +446,14 @@ public class OpenDataUpdatesPiveau {
...
@@ -431,14 +446,14 @@ public class OpenDataUpdatesPiveau {
return
false
;
return
false
;
}
}
final
String
newestDatasetId
=
ckanAPI
.
findNewestDataset
(
update
.
collectionId
);
final
Optional
<
String
>
newestDatasetId
=
findNewestDataset
(
update
.
collectionId
);
if
(
newestDatasetId
==
null
)
{
if
(
newestDatasetId
.
isEmpty
()
)
{
log
.
error
(
"In der Collection {} gibt es keinen Datensatz."
,
update
.
collectionId
);
log
.
error
(
"In der Collection {} gibt es keinen Datensatz."
,
update
.
collectionId
);
return
false
;
return
false
;
}
}
final
JSONObject
existingDataset
=
ckanAPI
.
readDataset
(
newestDatasetId
);
final
JSONObject
existingDataset
=
ckanAPI
.
readDataset
(
newestDatasetId
.
get
()
);
log
.
info
(
"Änderung erkannt an Dataset "
+
newestDatasetId
);
log
.
info
(
"Änderung erkannt an Dataset "
+
newestDatasetId
);
final
String
timeNow
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_DATE_TIME
);
final
String
timeNow
=
LocalDateTime
.
now
().
format
(
DateTimeFormatter
.
ISO_DATE_TIME
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment