Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

Commit

Permalink
Starting to work on Epic #298
Browse files Browse the repository at this point in the history
  • Loading branch information
seustachi committed Nov 9, 2014
1 parent 1245dda commit e84a195
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 0 deletions.
27 changes: 27 additions & 0 deletions HDX-System/src/main/java/org/ocha/hdx/jobs/MetadataUpdater.java
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);
}
}

}
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();

}
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;
}

}
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;
}

}

0 comments on commit e84a195

Please sign in to comment.