-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
45 changed files
with
2,537 additions
and
11 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
...i/api/src/main/java/com/devonfw/keywi/general/common/api/to/AbstractSearchCriteriaTo.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,32 @@ | ||
package com.devonfw.keywi.general.common.api.to; | ||
|
||
import org.springframework.data.domain.Pageable; | ||
|
||
import com.devonfw.module.basic.common.api.to.AbstractTo; | ||
|
||
/** | ||
* Abstract {@link AbstractTo TO} for search criteria. | ||
*/ | ||
public abstract class AbstractSearchCriteriaTo extends AbstractTo { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private Pageable pageable; | ||
|
||
/** | ||
* @return the {@link Pageable} containing the optional pagination information or {@code null}. | ||
*/ | ||
public Pageable getPageable() { | ||
|
||
return this.pageable; | ||
} | ||
|
||
/** | ||
* @param pageable new value of {@link #getPageable()}. | ||
*/ | ||
public void setPageable(Pageable pageable) { | ||
|
||
this.pageable = pageable; | ||
} | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
keywi/api/src/main/java/com/devonfw/keywi/keymanagement/common/api/KeyItem.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,38 @@ | ||
package com.devonfw.keywi.keymanagement.common.api; | ||
|
||
import com.devonfw.module.basic.common.api.reference.IdRef; | ||
|
||
/** | ||
* Interface for an item of an {@link #getKeyListId() owning} {@link KeyList}. | ||
*/ | ||
public interface KeyItem extends KeyObject { | ||
|
||
/** Property name for {@link #getValue()}. */ | ||
String PROPERTY_VALUE = "value"; | ||
|
||
/** Column name for {@link #getValue()}. */ | ||
String COLUMN_VALUE = "value"; | ||
|
||
/** | ||
* @return the optional value of this item. May be {@code null}. | ||
* @see KeyList#isValueRequired() | ||
* @see KeyList#getValuePattern() | ||
*/ | ||
String getValue(); | ||
|
||
/** | ||
* @param value new value of {@link #getValue()}. | ||
*/ | ||
void setValue(String value); | ||
|
||
/** | ||
* @return the {@link IdRef} pointing to the {@link KeyList} owning this item. | ||
*/ | ||
IdRef<KeyList> getKeyListId(); | ||
|
||
/** | ||
* @param keyListId new value of {@link #getKeyListId()}. | ||
*/ | ||
void setKeyListId(IdRef<KeyList> keyListId); | ||
|
||
} |
78 changes: 78 additions & 0 deletions
78
keywi/api/src/main/java/com/devonfw/keywi/keymanagement/common/api/KeyList.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,78 @@ | ||
package com.devonfw.keywi.keymanagement.common.api; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
import com.devonfw.keywi.keymanagement.dataaccess.api.datatype.KeyItemProperty; | ||
|
||
/** | ||
* Interface for a list of {@link KeyItem}s. | ||
*/ | ||
public interface KeyList extends KeyObject { | ||
|
||
/** | ||
* @return {@code true} if the {@link KeyItem#getKeyListId() containing} {@link KeyItem}s shall be cached by clients, | ||
* {@code false} otherwise. A {@link KeyList} with up to {@code 100} {@link KeyItem}s should always be cached | ||
* while lists with more than {@code 10.000} {@link KeyItem}s should never be cached. | ||
*/ | ||
boolean isCacheable(); | ||
|
||
/** | ||
* @param cacheable new value of {@link #isCacheable()}. Changing will have complex implications and should be | ||
* considered with care. | ||
*/ | ||
void setCacheable(boolean cacheable); | ||
|
||
/** | ||
* @return the {@link KeyItemProperty property} to sort the {@link KeyItem}s by default. Defaults to | ||
* {@link KeyItemProperty#NAME} and may not be {@code null}. | ||
*/ | ||
KeyItemProperty getOrdering(); | ||
|
||
/** | ||
* @param ordering new value of {@link #getOrdering()}. May not be {@code null}. | ||
*/ | ||
void setOrdering(KeyItemProperty ordering); | ||
|
||
/** | ||
* @return {@code true} if the {@link KeyItem#getValue() value} of the {@link KeyItem#getKeyListId() owned} | ||
* {@link KeyItem}s is required and may not be {@code null} or {@link String#isEmpty() empty}, {@code false} | ||
* otherwise (if it is optional and may be {@code null}). | ||
* @see #getValuePattern() | ||
*/ | ||
boolean isValueRequired(); | ||
|
||
/** | ||
* @param valueRequired new value of {@link #isValueRequired()}. Please note that changing this value to {@code true} | ||
* can make existing {@link KeyItem}s in database invalid. | ||
*/ | ||
void setValueRequired(boolean valueRequired); | ||
|
||
/** | ||
* @return the optional regular expression {@link Pattern} the {@link KeyItem#getValue() values} of | ||
* {@link KeyItem#getKeyListId() owned} {@link KeyItem}s have to match if they are not empty. May be | ||
* {@code null} if any value is considered valid. | ||
* @see #isValueRequired() | ||
*/ | ||
Pattern getValuePattern(); | ||
|
||
/** | ||
* @param valuePattern new value of {@link #getValuePattern()}. Please note that changing this value can make existing | ||
* {@link KeyItem}s in database invalid. | ||
*/ | ||
void setValuePattern(Pattern valuePattern); | ||
|
||
/** | ||
* @return the identifier of the additional permission required to manage this {@link KeyList} and its | ||
* {@link KeyItem}s. Then to save or even delete a {@link KeyItem} {@link KeyItem#getKeyListId() owned} by | ||
* this {@link KeyList} will additionally require that the user has the specified permission. Please note that | ||
* reading {@link KeyItem}s is not affected by this permission. May be {@code null} to only require standard | ||
* permissions. | ||
*/ | ||
String getPermission(); | ||
|
||
/** | ||
* @param permission new value of {@link #getPermission()}. | ||
*/ | ||
void setPermission(String permission); | ||
|
||
} |
70 changes: 70 additions & 0 deletions
70
keywi/api/src/main/java/com/devonfw/keywi/keymanagement/common/api/KeyObject.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,70 @@ | ||
package com.devonfw.keywi.keymanagement.common.api; | ||
|
||
import com.devonfw.keywi.general.common.api.ApplicationEntity; | ||
|
||
/** | ||
* Interface for item of | ||
*/ | ||
public interface KeyObject extends ApplicationEntity { | ||
|
||
/** Property name for {@link #getKey()}. */ | ||
String PROPERTY_KEY = "key"; | ||
|
||
/** Column name for {@link #getKey()}. */ | ||
String COLUMN_KEY = "business_key"; | ||
|
||
/** Property name for {@link #getName()}. */ | ||
String PROPERTY_NAME = "name"; | ||
|
||
/** Column name for {@link #getName()}. */ | ||
String COLUMN_NAME = "name"; | ||
|
||
/** Property name for {@link #getComment()}. */ | ||
String PROPERTY_COMMENT = "comment"; | ||
|
||
/** Column name for {@link #getComment()}. */ | ||
String COLUMN_COMMENT = "comment"; | ||
|
||
/** | ||
* @return keyId | ||
*/ | ||
String getKey(); | ||
|
||
/** | ||
* @param key setter for key attribute | ||
*/ | ||
void setKey(String key); | ||
|
||
/** | ||
* @return nameId | ||
*/ | ||
String getName(); | ||
|
||
/** | ||
* @param name setter for name attribute | ||
*/ | ||
void setName(String name); | ||
|
||
/** | ||
* @return descriptionId | ||
*/ | ||
String getComment(); | ||
|
||
/** | ||
* @param description setter for description attribute | ||
*/ | ||
void setComment(String description); | ||
|
||
/** | ||
* @return {@code true} if this item is disabled (deprecated) and may not be selected anymore. It can still be loaded | ||
* and displayed but it should not be available anymore for selection and should be considered as invalid when | ||
* saving data. Regular items are called active and will return {@code false} here. | ||
*/ | ||
boolean isDisabled(); | ||
|
||
/** | ||
* @param disabled new value of {@link #isDisabled()}. | ||
*/ | ||
void setDisabled(boolean disabled); | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
...rc/main/java/com/devonfw/keywi/keymanagement/dataaccess/api/datatype/KeyItemProperty.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,54 @@ | ||
package com.devonfw.keywi.keymanagement.dataaccess.api.datatype; | ||
|
||
import com.devonfw.keywi.keymanagement.common.api.KeyItem; | ||
import com.devonfw.keywi.keymanagement.common.api.KeyList; | ||
import com.devonfw.keywi.keymanagement.common.api.KeyObject; | ||
|
||
/** | ||
* Enum with the properties of a {@link KeyItem}. | ||
* | ||
* @see KeyList#getOrdering() | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public enum KeyItemProperty { | ||
|
||
/** {@link KeyItemProperty} for {@link KeyObject#getName()}. */ | ||
NAME(KeyObject.PROPERTY_NAME, KeyObject.COLUMN_NAME), | ||
|
||
/** {@link KeyItemProperty} for {@link KeyObject#getKey()}. */ | ||
KEY(KeyObject.PROPERTY_KEY, KeyObject.COLUMN_KEY), | ||
|
||
/** {@link KeyItemProperty} for {@link KeyObject#getComment()}. */ | ||
COMMENT(KeyObject.PROPERTY_COMMENT, KeyObject.COLUMN_COMMENT), | ||
|
||
/** {@link KeyItemProperty} for {@link KeyItem#getName()}. */ | ||
VALUE(KeyItem.PROPERTY_VALUE, KeyItem.COLUMN_VALUE); | ||
|
||
private final String columnName; | ||
|
||
private final String propertyName; | ||
|
||
private KeyItemProperty(String fieldName, String columnName) { | ||
|
||
this.propertyName = fieldName; | ||
this.columnName = columnName; | ||
} | ||
|
||
/** | ||
* @return the Java property name (e.g. "key" for "getKey()"). | ||
*/ | ||
public String getPropertyName() { | ||
|
||
return this.propertyName; | ||
} | ||
|
||
/** | ||
* @return the {@link javax.persistence.Column#name() column name} in the database. | ||
*/ | ||
public String getColumnName() { | ||
|
||
return this.columnName; | ||
} | ||
|
||
} |
72 changes: 72 additions & 0 deletions
72
keywi/api/src/main/java/com/devonfw/keywi/keymanagement/logic/api/to/KeyItemEto.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,72 @@ | ||
package com.devonfw.keywi.keymanagement.logic.api.to; | ||
|
||
import java.util.Objects; | ||
|
||
import com.devonfw.keywi.keymanagement.common.api.KeyItem; | ||
import com.devonfw.keywi.keymanagement.common.api.KeyList; | ||
import com.devonfw.module.basic.common.api.reference.IdRef; | ||
|
||
/** | ||
* {@link com.devonfw.module.basic.common.api.to.AbstractEto ETO} for {@link KeyItem}. | ||
*/ | ||
public class KeyItemEto extends KeyObjectEto implements KeyItem { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private String value; | ||
|
||
private IdRef<KeyList> keyListId; | ||
|
||
@Override | ||
public String getValue() { | ||
|
||
return this.value; | ||
} | ||
|
||
@Override | ||
public void setValue(String value) { | ||
|
||
this.value = value; | ||
} | ||
|
||
@Override | ||
public IdRef<KeyList> getKeyListId() { | ||
|
||
return this.keyListId; | ||
} | ||
|
||
@Override | ||
public void setKeyListId(IdRef<KeyList> keyListId) { | ||
|
||
this.keyListId = keyListId; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
|
||
return Objects.hash(super.hashCode(), this.keyListId, this.value); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
|
||
if (this == obj) { | ||
return true; | ||
} | ||
if (obj == null) { | ||
return false; | ||
} | ||
// class check will be done by super type EntityTo! | ||
if (!super.equals(obj)) { | ||
return false; | ||
} | ||
KeyItemEto other = (KeyItemEto) obj; | ||
if (!Objects.equals(this.keyListId, other.keyListId)) { | ||
return false; | ||
} else if (!Objects.equals(this.value, other.value)) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
} |
Oops, something went wrong.