-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Data Normalization Mapper: Enhancements to getAllItems Method
Mapper to normalize the information fetched from GeneralItem and QuantizableItem, restructuring of the 'getAllItems' method to return the normalized and mapped list, and adding a header with the attributes returned in the mapper.
- Loading branch information
1 parent
5a11c01
commit ced21b3
Showing
10 changed files
with
109 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.consola.lis.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class ItemInfoDTO { | ||
private String id; | ||
private String state; | ||
private String category; | ||
private String wallet; | ||
private String[] attributes; | ||
private boolean quantizable; | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/java/com/consola/lis/util/mapper/InventoryItemMapper.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 com.consola.lis.util.mapper; | ||
|
||
import com.consola.lis.dto.CategoryDTO; | ||
import com.consola.lis.dto.ItemInfoDTO; | ||
import com.consola.lis.dto.UserDTO; | ||
import com.consola.lis.model.entity.Category; | ||
import com.consola.lis.model.entity.GeneralItem; | ||
import com.consola.lis.model.entity.User; | ||
import org.json.JSONObject; | ||
|
||
import java.util.Set; | ||
|
||
public class InventoryItemMapper { | ||
private InventoryItemMapper () { | ||
} | ||
public static ItemInfoDTO mapToItemInfoDTO(GeneralItem generalItem, Category category) { | ||
|
||
return ItemInfoDTO.builder() | ||
.id(generalItem.getItemId()) | ||
.state(String.valueOf(generalItem.getState())) | ||
.category(category.getCategoryName()) | ||
.wallet(String.valueOf(generalItem.getWallet()).replace("_"," ")) | ||
.quantizable(category.getQuantizable()) | ||
.attributes(convertAttributes(generalItem.getAttributes())) | ||
.build(); | ||
} | ||
|
||
|
||
private static String[] convertAttributes(String attributes){ | ||
JSONObject jsonObject = new JSONObject(attributes); | ||
Set<String> keySet = jsonObject.keySet(); | ||
return keySet.toArray(new String[0]); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...va/com/consola/lis/mapper/UserMapper.java → ...m/consola/lis/util/mapper/UserMapper.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
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