This repository has been archived by the owner on Mar 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
HDX-System/src/main/java/org/ocha/hdx/jobs/MetadataUpdater.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,27 @@ | ||
package org.ocha.hdx.jobs; | ||
|
||
import org.ocha.hdx.service.HDXService; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
|
||
public class MetadataUpdater implements Runnable { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(MetadataUpdater.class); | ||
|
||
@Autowired | ||
private HDXService hdxService; | ||
|
||
@Override | ||
@Scheduled(fixedDelay = 100000, initialDelay = 100000) | ||
public void run() { | ||
try { | ||
// ... | ||
|
||
} catch (final Throwable e) { | ||
log.error(e.toString(), e); | ||
} | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
HDX-System/src/main/java/org/ocha/hdx/persistence/dao/ckan/DataSerieToCuratedDatasetDAO.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,15 @@ | ||
package org.ocha.hdx.persistence.dao.ckan; | ||
|
||
import java.util.List; | ||
|
||
import org.ocha.hdx.persistence.entity.ckan.DataSerieToCuratedDataset; | ||
|
||
public interface DataSerieToCuratedDatasetDAO { | ||
|
||
/** | ||
* | ||
* @return the datasets where lastMetadataUpdate > lastMetadataPush | ||
*/ | ||
public List<DataSerieToCuratedDataset> getDatasetsWithUnsyncedMetadata(); | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...tem/src/main/java/org/ocha/hdx/persistence/dao/ckan/DataSerieToCuratedDatasetDAOImpl.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,15 @@ | ||
package org.ocha.hdx.persistence.dao.ckan; | ||
|
||
import java.util.List; | ||
|
||
import org.ocha.hdx.persistence.entity.ckan.DataSerieToCuratedDataset; | ||
|
||
public class DataSerieToCuratedDatasetDAOImpl implements DataSerieToCuratedDatasetDAO { | ||
|
||
@Override | ||
public List<DataSerieToCuratedDataset> getDatasetsWithUnsyncedMetadata() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
124 changes: 124 additions & 0 deletions
124
HDX-System/src/main/java/org/ocha/hdx/persistence/entity/ckan/DataSerieToCuratedDataset.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,124 @@ | ||
package org.ocha.hdx.persistence.entity.ckan; | ||
|
||
import java.util.Date; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.JoinColumn; | ||
import javax.persistence.ManyToOne; | ||
import javax.persistence.SequenceGenerator; | ||
import javax.persistence.Table; | ||
import javax.persistence.Temporal; | ||
import javax.persistence.TemporalType; | ||
import javax.persistence.UniqueConstraint; | ||
|
||
import org.hibernate.annotations.ForeignKey; | ||
import org.ocha.hdx.persistence.entity.curateddata.IndicatorType; | ||
import org.ocha.hdx.persistence.entity.curateddata.Source; | ||
|
||
@Entity | ||
@Table(name = "hdx_dataserie_to_curated_dataset", uniqueConstraints = @UniqueConstraint(columnNames = { "source_id", "indicator_type_id" })) | ||
@SequenceGenerator(name = "hdx_dataserie_metadata_seq", sequenceName = "hdx_dataserie_metadata_seq") | ||
public class DataSerieToCuratedDataset { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO, generator = "hdx_dataserie_metadata_seq") | ||
@Column(name = "id", nullable = false) | ||
private long id; | ||
|
||
@ManyToOne | ||
@ForeignKey(name = "fk__dataserie_to_curated_data_to_source") | ||
@JoinColumn(name = "source_id", nullable = false) | ||
private Source source; | ||
|
||
@ManyToOne | ||
@ForeignKey(name = "fk__dataserie_to_curated_data_to_indicator_type") | ||
@JoinColumn(name = "indicator_type_id", nullable = false) | ||
private IndicatorType indicatorType; | ||
|
||
private String datasetName; | ||
|
||
@Column(name = "last_metadata_update", nullable = true, updatable = true) | ||
@Temporal(TemporalType.DATE) | ||
private Date lastMetadataUpdate; | ||
|
||
@Column(name = "last_metadata_push", nullable = true, updatable = true) | ||
@Temporal(TemporalType.DATE) | ||
private Date lastMetadataPush; | ||
|
||
@Column(name = "last_data_update", nullable = true, updatable = true) | ||
@Temporal(TemporalType.DATE) | ||
private Date lastDataUpdate; | ||
|
||
@Column(name = "last_data_push", nullable = true, updatable = true) | ||
@Temporal(TemporalType.DATE) | ||
private Date lastDataPush; | ||
|
||
public long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(final long id) { | ||
this.id = id; | ||
} | ||
|
||
public Source getSource() { | ||
return source; | ||
} | ||
|
||
public void setSource(final Source source) { | ||
this.source = source; | ||
} | ||
|
||
public IndicatorType getIndicatorType() { | ||
return indicatorType; | ||
} | ||
|
||
public void setIndicatorType(final IndicatorType indicatorType) { | ||
this.indicatorType = indicatorType; | ||
} | ||
|
||
public String getDatasetName() { | ||
return datasetName; | ||
} | ||
|
||
public void setDatasetName(final String datasetName) { | ||
this.datasetName = datasetName; | ||
} | ||
|
||
public Date getLastMetadataUpdate() { | ||
return lastMetadataUpdate; | ||
} | ||
|
||
public void setLastMetadataUpdate(final Date lastMetadataUpdate) { | ||
this.lastMetadataUpdate = lastMetadataUpdate; | ||
} | ||
|
||
public Date getLastMetadataPush() { | ||
return lastMetadataPush; | ||
} | ||
|
||
public void setLastMetadataPush(final Date lastMetadataPush) { | ||
this.lastMetadataPush = lastMetadataPush; | ||
} | ||
|
||
public Date getLastDataUpdate() { | ||
return lastDataUpdate; | ||
} | ||
|
||
public void setLastDataUpdate(final Date lastDataUpdate) { | ||
this.lastDataUpdate = lastDataUpdate; | ||
} | ||
|
||
public Date getLastDataPush() { | ||
return lastDataPush; | ||
} | ||
|
||
public void setLastDataPush(final Date lastDataPush) { | ||
this.lastDataPush = lastDataPush; | ||
} | ||
|
||
} |