-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hlm 3372 enhance inventory flow backend fixes (#623)
* HLM-3372: added changes required to fix quantity, Sender Receiver enum * HLM-3372: Sender and Receiver id validator * HLM-3372: updated all reference for SenderType and Receiver Type enum * HLM-3372: stock model updated, removed size annotations from referenceidtype enum field * HLM-3372: Min validation added for integer type of quantity * HLM-3372: test cases updated * HLM-5004 Added max value and decimal condition for quantity in stock, added component and order annotation for SSenderIdReceiverIdEqualsValidator * HLM-5004 Custom JsonDeserializer validator IntegerValidator added in health-services-models * hlm-5004 added custom exception and a custom exception handler to handle the integer validator exception * hlm-5004 optimized imports and added code comments * hlm-5004 CustomIntegerSerializer added and unnecessary validators removed * hlm-5004 Registered the CustomIntegerDeserializer with objectMapper for Integer class * hlm-5004 Removed line of code that was removing all the invalid entities from the list in SSenderIdReceiverIdEqualsValidator * hlm-5004 changes in test configurations and optimized imports * hlm-5004 added row version validator for stock delete * hlm-5004 dateOfEntry field was handled in StockRowMapper to return null if no value is present and description was added to stock contact for transactionReason * updated pom.xml for health campaign models * Revert "updated pom.xml for health campaign models" This reverts commit 035c787. --------- Co-authored-by: syed-egov <[email protected]>
- Loading branch information
1 parent
dee30a1
commit fe8c32b
Showing
17 changed files
with
288 additions
and
62 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
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
43 changes: 43 additions & 0 deletions
43
...models/src/main/java/org/egov/common/models/core/validator/CustomIntegerDeserializer.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,43 @@ | ||
package org.egov.common.models.core.validator; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import org.egov.tracer.model.CustomException; | ||
|
||
// Custom deserializer for Integer values | ||
public class CustomIntegerDeserializer extends StdDeserializer<Integer> { | ||
|
||
public CustomIntegerDeserializer() { | ||
this(null); | ||
} | ||
|
||
public CustomIntegerDeserializer(Class<?> vc) { | ||
super(vc); | ||
} | ||
|
||
@Override | ||
public Integer deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { | ||
|
||
// Read the JSON tree from the parser | ||
JsonNode node = jsonParser.getCodec().readTree(jsonParser); | ||
System.out.println(node.toString()); | ||
if(node.asLong() > Integer.MAX_VALUE){ | ||
throw new CustomException("INVALID_INPUT","Value must be an Integer"); | ||
} | ||
|
||
// Parse the quantity as an integer | ||
int quantity = node.asInt(); | ||
|
||
// Check if the parsed quantity matches the original string representation | ||
if ((double) quantity != Double.parseDouble(node.asText())) { | ||
throw new CustomException("INVALID_INPUT", "Quantity must be an integer"); | ||
} | ||
|
||
// Return the parsed quantity | ||
return quantity; | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
...es/health-services-models/src/main/java/org/egov/common/models/stock/ReferenceIdType.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 org.egov.common.models.stock; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public enum ReferenceIdType { | ||
PROJECT("PROJECT"), | ||
OTHER("OTHER"); | ||
private String value; | ||
|
||
ReferenceIdType(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return String.valueOf(value); | ||
} | ||
|
||
@JsonCreator | ||
public static ReferenceIdType fromValue(String text) { | ||
for (ReferenceIdType b : ReferenceIdType.values()) { | ||
if (String.valueOf(b.value).equals(text)) { | ||
return b; | ||
} | ||
} | ||
return null; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...health-services-models/src/main/java/org/egov/common/models/stock/SenderReceiverType.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,34 @@ | ||
package org.egov.common.models.stock; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public enum SenderReceiverType { | ||
WAREHOUSE("WAREHOUSE"), | ||
|
||
STAFF("STAFF"); | ||
|
||
private String value; | ||
|
||
SenderReceiverType(String value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
@JsonValue | ||
public String toString() { | ||
return String.valueOf(value); | ||
} | ||
|
||
@JsonCreator | ||
public static SenderReceiverType fromValue(String text) { | ||
for (SenderReceiverType b : SenderReceiverType.values()) { | ||
if (String.valueOf(b.value).equals(text)) { | ||
return b; | ||
} | ||
} | ||
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
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
Oops, something went wrong.