Skip to content

Commit

Permalink
Processing of modified DHIS2 tracked entity instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
volsch committed Dec 1, 2018
1 parent 4c7550d commit 9d652a9
Show file tree
Hide file tree
Showing 56 changed files with 2,267 additions and 861 deletions.
6 changes: 3 additions & 3 deletions app/src/test/java/org/dhis2/fhir/adapter/AbstractAppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ public abstract class AbstractAppTest
private CacheManager fhirCacheManager;

@Autowired
@Qualifier( "webHookRequestQueueJmsTemplate" )
private JmsTemplate webHookRequestQueueJmsTemplate;
@Qualifier( "fhirRestHookRequestQueueJmsTemplate" )
private JmsTemplate fhirRestHookRequestQueueJmsTemplate;

@Autowired
@Qualifier( "fhirResourceQueueJmsTemplate" )
Expand Down Expand Up @@ -203,7 +203,7 @@ protected void waitForEmptyResourceQueue() throws Exception
long messageCount;
do
{
messageCount = getQueueMessageCount( webHookRequestQueueJmsTemplate, null ) +
messageCount = getQueueMessageCount( fhirRestHookRequestQueueJmsTemplate, null ) +
getQueueMessageCount( fhirResourceQueueJmsTemplate, null );
if ( messageCount > 0 )
{
Expand Down
22 changes: 22 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
<description>Contains the common framework and utility classes that do neither depend on DHIS2 (except DHIS2 value type) nor on FHIR.</description>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-artemis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-server</artifactId>
Expand All @@ -63,9 +67,27 @@
<artifactId>spring-data-rest-webmvc</artifactId>
</dependency>

<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.dhis2.fhir.adapter.data.model;

/*
* Copyright (c) 2004-2018, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import java.io.Serializable;

/**
* Combines a group of data items that are processed together. A data group has
* a unique ID that contains more or less primitive values which make it possible
* to lookup the data group.
*
* @author volsch
*/
public interface DataGroup extends Serializable
{
DataGroupId getGroupId();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.dhis2.fhir.adapter.data.model;

/*
* Copyright (c) 2004-2018, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import java.io.Serializable;

/**
* The ID of a data group. The ID must contain only more or less primitive values
* (strings and UUIDs are allowed).
*
* @author volsch
*/
public interface DataGroupId extends Serializable
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.dhis2.fhir.adapter.data.model;

/*
* Copyright (c) 2004-2018, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import javax.annotation.Nonnull;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
import java.time.Instant;

/**
* Contains the update status of a data group.
*
* @param <G> the group to which the update data belongs to.
* @author volsch
*/
@MappedSuperclass
public abstract class DataGroupUpdate<G extends DataGroup> implements Serializable
{
private static final long serialVersionUID = -2051276256396499975L;

private Instant lastUpdated;

public DataGroupUpdate()
{
super();
}

public DataGroupUpdate( @Nonnull Instant lastUpdated )
{
this.lastUpdated = lastUpdated;
}

@Transient
public abstract G getGroup();

public abstract void setGroup( G group );

@Basic
@Column( name = "last_updated", nullable = false )
public Instant getLastUpdated()
{
return lastUpdated;
}

public void setLastUpdated( Instant remoteLastUpdate )
{
this.lastUpdated = remoteLastUpdate;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.dhis2.fhir.adapter.data.model;

/*
* Copyright (c) 2004-2018, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import javax.annotation.Nonnull;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
import java.time.Instant;

/**
* Contains the reference of an item that has already been processed recently and
* must not be processed again currently (e.g. overlapping polls).
*
* @param <I> the ID class of the processed items.
* @param <G> the concrete type of the group of the ID.
* @author volsch
*/
@MappedSuperclass
public abstract class ProcessedItem<I extends ProcessedItemId<G>, G extends DataGroup> implements Serializable
{
private static final long serialVersionUID = -2744716962486660280L;

private Instant processedAt;

public ProcessedItem()
{
super();
}

public ProcessedItem( @Nonnull Instant processedAt )
{
this.processedAt = processedAt;
}

@Transient
public abstract I getId();

public abstract void setId( I id );

@Column( name = "processed_at", nullable = false )
public Instant getProcessedAt()
{
return processedAt;
}

public void setProcessedAt( Instant processedAt )
{
this.processedAt = processedAt;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package org.dhis2.fhir.adapter.data.model;

/*
* Copyright (c) 2004-2018, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import javax.annotation.Nonnull;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Objects;

/**
* Contains the reference (as an ID) of an item that has already been
* processed recently and must not be processed again currently
* (e.g. overlapping polls).
*
* @param <G> the concrete type of the group of the ID.
* @author volsch
*/
@MappedSuperclass
public abstract class ProcessedItemId<G extends DataGroup> implements Serializable
{
private static final long serialVersionUID = -2744716962486660280L;

private String processedId;

public ProcessedItemId()
{
super();
}

public ProcessedItemId( @Nonnull String processedId )
{
this.processedId = processedId;
}

@Transient
public abstract G getGroup();

public abstract void setGroup( G group );

@Column( name = "processed_id", nullable = false )
public String getProcessedId()
{
return processedId;
}

public void setProcessedId( String processedId )
{
this.processedId = processedId;
}

@Override
public boolean equals( Object o )
{
if ( this == o ) return true;
if ( o == null || getClass() != o.getClass() ) return false;
ProcessedItemId that = (ProcessedItemId) o;
return Objects.equals( processedId, that.processedId );
}

@Override
public int hashCode()
{
return Objects.hash( processedId );
}
}
Loading

0 comments on commit 9d652a9

Please sign in to comment.