-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MET-5961 add initial definition for debias processing state in db
- Loading branch information
1 parent
f8479c6
commit 663a245
Showing
8 changed files
with
188 additions
and
1 deletion.
There are no files selected for viewing
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
10 changes: 10 additions & 0 deletions
10
src/main/java/eu/europeana/metis/sandbox/common/debias/Event.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,10 @@ | ||
package eu.europeana.metis.sandbox.common.debias; | ||
|
||
/** | ||
* Verbs Event | ||
*/ | ||
public enum Event { | ||
PROCESS, | ||
SUCCEED, | ||
FAIL | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/eu/europeana/metis/sandbox/common/debias/State.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,11 @@ | ||
package eu.europeana.metis.sandbox.common.debias; | ||
|
||
/** | ||
* Nouns/Adjectives State | ||
*/ | ||
public enum State { | ||
START, | ||
PROCESSING, | ||
COMPLETED, | ||
ERROR | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/eu/europeana/metis/sandbox/config/DebiasConfig.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,55 @@ | ||
package eu.europeana.metis.sandbox.config; | ||
|
||
import eu.europeana.metis.sandbox.common.debias.Event; | ||
import eu.europeana.metis.sandbox.common.debias.State; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.statemachine.config.EnableStateMachine; | ||
import org.springframework.statemachine.config.StateMachineConfigurerAdapter; | ||
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer; | ||
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer; | ||
|
||
@Configuration | ||
@EnableStateMachine | ||
public class DebiasConfig extends StateMachineConfigurerAdapter<State, Event> { | ||
|
||
@Override | ||
public void configure(StateMachineStateConfigurer<State, Event> states) throws Exception { | ||
states | ||
.withStates() | ||
.initial(State.START) | ||
.state(State.PROCESSING) | ||
.state(State.ERROR) | ||
.end(State.COMPLETED); | ||
} | ||
|
||
@Override | ||
public void configure(StateMachineTransitionConfigurer<State, Event> transitions) throws Exception { | ||
transitions | ||
.withExternal() | ||
.source(State.START).target(State.PROCESSING) | ||
.event(Event.PROCESS) | ||
.and() | ||
.withExternal() | ||
.source(State.PROCESSING).target(State.ERROR) | ||
.event(Event.FAIL) | ||
.and() | ||
.withExternal() | ||
.source(State.ERROR).target(State.PROCESSING) | ||
.event(Event.PROCESS) | ||
.and() | ||
.withExternal() | ||
.source(State.PROCESSING).target(State.COMPLETED) | ||
.event(Event.SUCCEED); | ||
} | ||
|
||
// @Bean | ||
// public StateMachineRuntimePersister<State,Event,String> stringStateMachineRuntimePersister() { | ||
// return new JpaPersistingStateMachineInterceptor<>(jpaStateMachineRepository);; | ||
// } | ||
// @Override | ||
// public void configure(StateMachineConfigurationConfigurer<State, Event> config) throws Exception { | ||
// config.withPersistence() | ||
// .runtimePersister() | ||
// } | ||
} | ||
|
85 changes: 85 additions & 0 deletions
85
src/main/java/eu/europeana/metis/sandbox/entity/debias/DetectionEntity.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,85 @@ | ||
package eu.europeana.metis.sandbox.entity.debias; | ||
|
||
import eu.europeana.metis.sandbox.entity.DatasetEntity; | ||
import jakarta.persistence.CascadeType; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.OneToOne; | ||
import jakarta.persistence.Table; | ||
import java.time.ZonedDateTime; | ||
|
||
/** | ||
* The type Detection entity. | ||
*/ | ||
@Entity | ||
@Table(name = "dataset_debias_detect") | ||
public class DetectionEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@OneToOne(cascade = CascadeType.PERSIST) | ||
@JoinColumn(name = "dataset_id", referencedColumnName = "datasetId") | ||
private DatasetEntity datasetId; | ||
|
||
private String state; | ||
|
||
@Column(insertable = false, updatable = false) | ||
private ZonedDateTime createdDate; | ||
|
||
|
||
/** | ||
* Instantiates a new Detection entity. | ||
*/ | ||
public DetectionEntity() { | ||
// provide explicit no-args constructor as it is required for Hibernate | ||
} | ||
|
||
/** | ||
* Instantiates a new Detection entity. | ||
* | ||
* @param datasetId the dataset id | ||
* @param state the state | ||
*/ | ||
public DetectionEntity(DatasetEntity datasetId, String state) { | ||
this.datasetId = datasetId; | ||
this.state = state; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public DatasetEntity getDatasetId() { | ||
return datasetId; | ||
} | ||
|
||
public void setDatasetId(DatasetEntity datasetId) { | ||
this.datasetId = datasetId; | ||
} | ||
|
||
public String getState() { | ||
return state; | ||
} | ||
|
||
public void setState(String state) { | ||
this.state = state; | ||
} | ||
|
||
public ZonedDateTime getCreatedDate() { | ||
return createdDate; | ||
} | ||
|
||
public void setCreatedDate(ZonedDateTime createdDate) { | ||
this.createdDate = createdDate; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/eu/europeana/metis/sandbox/service/debias/DebiasStateMachineService.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,8 @@ | ||
package eu.europeana.metis.sandbox.service.debias; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class DebiasStateMachineService { | ||
|
||
} |
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
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