-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#677): support for archiving entity with custom interfaces
- Loading branch information
Showing
8 changed files
with
217 additions
and
7 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
evita_api/src/main/java/io/evitadb/api/proxy/WithScope.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,46 @@ | ||
/* | ||
* | ||
* _ _ ____ ____ | ||
* _____ _(_) |_ __ _| _ \| __ ) | ||
* / _ \ \ / / | __/ _` | | | | _ \ | ||
* | __/\ V /| | || (_| | |_| | |_) | | ||
* \___| \_/ |_|\__\__,_|____/|____/ | ||
* | ||
* Copyright (c) 2023-2024 | ||
* | ||
* Licensed under the Business Source License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://github.com/FgForrest/evitaDB/blob/master/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.evitadb.api.proxy; | ||
|
||
import io.evitadb.dataType.Scope; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Interface can be implemented by client model classes that want to access scope information on the entity. | ||
* | ||
* @author Jan Novotný (novotny@fg.cz), FG Forrest a.s. (c) 2023 | ||
*/ | ||
public interface WithScope { | ||
|
||
/** | ||
* Retrieves the scope of the entity within the EvitaDB system. | ||
* The scope indicates whether the entity is active and resides in the live data set or is archived. | ||
* | ||
* @return the scope of the entity | ||
*/ | ||
@Nonnull | ||
Scope getScope(); | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
evita_api/src/main/java/io/evitadb/api/proxy/WithScopeEditor.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,45 @@ | ||
/* | ||
* | ||
* _ _ ____ ____ | ||
* _____ _(_) |_ __ _| _ \| __ ) | ||
* / _ \ \ / / | __/ _` | | | | _ \ | ||
* | __/\ V /| | || (_| | |_| | |_) | | ||
* \___| \_/ |_|\__\__,_|____/|____/ | ||
* | ||
* Copyright (c) 2023-2024 | ||
* | ||
* Licensed under the Business Source License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://github.com/FgForrest/evitaDB/blob/master/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.evitadb.api.proxy; | ||
|
||
import io.evitadb.dataType.Scope; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Interface can be implemented by client model classes that want to modify scope information on the entity. | ||
* | ||
* @author Jan Novotný (novotny@fg.cz), FG Forrest a.s. (c) 2023 | ||
*/ | ||
public interface WithScopeEditor extends WithScope { | ||
|
||
/** | ||
* Sets the scope of the entity in the EvitaDB system. The scope determines whether the entity is | ||
* currently active and resides in the live data set or is archived. | ||
* | ||
* @param scope the scope to set for the entity; must not be null | ||
*/ | ||
void setScope(@Nonnull Scope scope); | ||
|
||
} |
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
61 changes: 61 additions & 0 deletions
61
evita_api/src/main/java/io/evitadb/api/proxy/impl/entity/GetScopeMethodClassifier.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,61 @@ | ||
/* | ||
* | ||
* _ _ ____ ____ | ||
* _____ _(_) |_ __ _| _ \| __ ) | ||
* / _ \ \ / / | __/ _` | | | | _ \ | ||
* | __/\ V /| | || (_| | |_| | |_) | | ||
* \___| \_/ |_|\__\__,_|____/|____/ | ||
* | ||
* Copyright (c) 2023-2024 | ||
* | ||
* Licensed under the Business Source License, Version 1.1 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://github.com/FgForrest/evitaDB/blob/master/LICENSE | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.evitadb.api.proxy.impl.entity; | ||
|
||
import io.evitadb.api.proxy.WithScope; | ||
import io.evitadb.api.proxy.impl.SealedEntityProxyState; | ||
import one.edee.oss.proxycian.DirectMethodClassification; | ||
import one.edee.oss.proxycian.util.ReflectionUtils; | ||
|
||
/** | ||
* Identifies methods that are used to get entity scope from an entity and provides their implementation. | ||
* | ||
* @author Jan Novotný (novotny@fg.cz), FG Forrest a.s. (c) 2023 | ||
*/ | ||
public class GetScopeMethodClassifier extends DirectMethodClassification<Object, SealedEntityProxyState> { | ||
/** | ||
* We may reuse singleton instance since advice is stateless. | ||
*/ | ||
public static final GetScopeMethodClassifier INSTANCE = new GetScopeMethodClassifier(); | ||
|
||
public GetScopeMethodClassifier() { | ||
super( | ||
"getScope", | ||
(method, proxyState) -> { | ||
// We are interested only in abstract methods without arguments | ||
if (method.getParameterCount() > 0) { | ||
return null; | ||
} | ||
|
||
if (ReflectionUtils.isMatchingMethodPresentOn(method, WithScope.class)) { | ||
return (entityClassifier, theMethod, args, theState, invokeSuper) -> theState.entity().getScope(); | ||
} | ||
|
||
// this method is not classified by this implementation | ||
return null; | ||
} | ||
); | ||
} | ||
|
||
} |
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
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