-
Notifications
You must be signed in to change notification settings - Fork 75
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
13 changed files
with
377 additions
and
30 deletions.
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
56 changes: 56 additions & 0 deletions
56
...r.Core.Model/src/main/java/de/fraunhofer/iosb/ilt/frostserver/model/loader/DefPmHook.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,56 @@ | ||
/* | ||
* Copyright (C) 2023 Fraunhofer Institut IOSB, Fraunhoferstr. 1, D 76131 | ||
* Karlsruhe, Germany. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.fraunhofer.iosb.ilt.frostserver.model.loader; | ||
|
||
import de.fraunhofer.iosb.ilt.configurable.AnnotatedConfigurable; | ||
import de.fraunhofer.iosb.ilt.configurable.annotations.ConfigurableField; | ||
import de.fraunhofer.iosb.ilt.configurable.editor.EditorDouble; | ||
import de.fraunhofer.iosb.ilt.configurable.editor.EditorSubclass; | ||
|
||
/** | ||
* Pair of PmHook and Priority for said hook. | ||
*/ | ||
public class DefPmHook implements AnnotatedConfigurable<Void, Void> { | ||
|
||
@ConfigurableField(editor = EditorDouble.class, optional = true, | ||
label = "Priority", description = "Priority of the Hook. Hooks with lower priority are executed earlier.") | ||
@EditorDouble.EdOptsDouble(max = 100, min = -100, step = 0.1) | ||
private double priority; | ||
|
||
@ConfigurableField(editor = EditorSubclass.class, | ||
label = "PM Hooks", description = "Persistence Manager Hooks") | ||
@EditorSubclass.EdOptsSubclass(iface = PmHook.class, merge = true, nameField = "@class", shortenClassNames = true) | ||
private PmHook hook; | ||
|
||
public double getPriority() { | ||
return priority; | ||
} | ||
|
||
public void setPriority(double priority) { | ||
this.priority = priority; | ||
} | ||
|
||
public PmHook getHook() { | ||
return hook; | ||
} | ||
|
||
public void setHook(PmHook hook) { | ||
this.hook = hook; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...rver.Core.Model/src/main/java/de/fraunhofer/iosb/ilt/frostserver/model/loader/PmHook.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,25 @@ | ||
/* | ||
* Copyright (C) 2023 Fraunhofer Institut IOSB, Fraunhoferstr. 1, D 76131 | ||
* Karlsruhe, Germany. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.fraunhofer.iosb.ilt.frostserver.model.loader; | ||
|
||
/** | ||
* Interface for PersistenceManager-specific hooks. | ||
*/ | ||
public interface PmHook { | ||
|
||
} |
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
40 changes: 40 additions & 0 deletions
40
.../java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/factories/HookPostDelete.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,40 @@ | ||
/* | ||
* Copyright (C) 2023 Fraunhofer Institut IOSB, Fraunhoferstr. 1, D 76131 | ||
* Karlsruhe, Germany. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.fraunhofer.iosb.ilt.frostserver.persistence.pgjooq.factories; | ||
|
||
import de.fraunhofer.iosb.ilt.frostserver.model.core.PkValue; | ||
import de.fraunhofer.iosb.ilt.frostserver.persistence.pgjooq.JooqPersistenceManager; | ||
import de.fraunhofer.iosb.ilt.frostserver.util.exception.NoSuchEntityException; | ||
|
||
/** | ||
* A hook that can be registered on a table and will get executed after a | ||
* postDelete has happened. | ||
* | ||
* @author hylke | ||
*/ | ||
public interface HookPostDelete extends JooqPmHook { | ||
|
||
/** | ||
* | ||
* @param pm The PersistenceManager for database access. | ||
* @param entityId The entity ID that is going to be deleted. | ||
* @throws NoSuchEntityException if something is wrong. This will cancel the | ||
* action. | ||
*/ | ||
public void postDelete(JooqPersistenceManager pm, PkValue entityId) throws NoSuchEntityException; | ||
} |
47 changes: 47 additions & 0 deletions
47
.../java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/factories/HookPostInsert.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,47 @@ | ||
/* | ||
* Copyright (C) 2023 Fraunhofer Institut IOSB, Fraunhoferstr. 1, D 76131 | ||
* Karlsruhe, Germany. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.fraunhofer.iosb.ilt.frostserver.persistence.pgjooq.factories; | ||
|
||
import de.fraunhofer.iosb.ilt.frostserver.model.core.Entity; | ||
import de.fraunhofer.iosb.ilt.frostserver.persistence.pgjooq.JooqPersistenceManager; | ||
import de.fraunhofer.iosb.ilt.frostserver.util.exception.IncompleteEntityException; | ||
import de.fraunhofer.iosb.ilt.frostserver.util.exception.NoSuchEntityException; | ||
import java.util.Map; | ||
import org.jooq.Field; | ||
|
||
/** | ||
* A hook that can be registered on a table and will get executed before an | ||
* insert happens. | ||
* | ||
* @author hylke | ||
*/ | ||
public interface HookPostInsert extends JooqPmHook { | ||
|
||
/** | ||
* | ||
* @param pm The Persistence Manager to use for database queries. | ||
* @param entity The entity that is being inserted. | ||
* @param insertFields The fields being inserted. | ||
* @return true if the insert can continue, false if the insert should be | ||
* skipped without error. | ||
* @throws NoSuchEntityException If a related entity does not exist. | ||
* @throws IncompleteEntityException If the entity is not complete. | ||
*/ | ||
public boolean postInsertIntoDatabase(JooqPersistenceManager pm, Entity entity, Map<Field, Object> insertFields) throws NoSuchEntityException, IncompleteEntityException; | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
.../java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/factories/HookPostUpdate.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,35 @@ | ||
/* | ||
* Copyright (C) 2023 Fraunhofer Institut IOSB, Fraunhoferstr. 1, D 76131 | ||
* Karlsruhe, Germany. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.fraunhofer.iosb.ilt.frostserver.persistence.pgjooq.factories; | ||
|
||
import de.fraunhofer.iosb.ilt.frostserver.model.core.Entity; | ||
import de.fraunhofer.iosb.ilt.frostserver.model.core.PkValue; | ||
import de.fraunhofer.iosb.ilt.frostserver.persistence.pgjooq.JooqPersistenceManager; | ||
import de.fraunhofer.iosb.ilt.frostserver.util.exception.IncompleteEntityException; | ||
import de.fraunhofer.iosb.ilt.frostserver.util.exception.NoSuchEntityException; | ||
|
||
/** | ||
* A hook that can be registered on a table and will get executed after an | ||
* update has happened. | ||
* | ||
* @author hylke | ||
*/ | ||
public interface HookPostUpdate extends JooqPmHook { | ||
|
||
public void postUpdateInDatabase(JooqPersistenceManager pm, Entity entity, PkValue entityId) throws NoSuchEntityException, IncompleteEntityException; | ||
} |
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
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
27 changes: 27 additions & 0 deletions
27
...main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/factories/JooqPmHook.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 @@ | ||
/* | ||
* Copyright (C) 2023 Fraunhofer Institut IOSB, Fraunhoferstr. 1, D 76131 | ||
* Karlsruhe, Germany. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package de.fraunhofer.iosb.ilt.frostserver.persistence.pgjooq.factories; | ||
|
||
import de.fraunhofer.iosb.ilt.frostserver.model.loader.PmHook; | ||
|
||
/** | ||
* Interface for JooqPersistenceManager compatible Hooks. | ||
*/ | ||
public interface JooqPmHook extends PmHook { | ||
|
||
} |
Oops, something went wrong.