Sprint 1 - 3 Review Ticket
Team Issues / Plan
Planning, Assigned Role, etc. can all be found above
N@tM Presentation
Programming
Key Highlights
- Storing custom objects inside database, different ways.
- Could be boring, make three columns, but that can’t happen everywhere, so intentionally stored custom object
Method 1:
- Annotations, create variable not stored in database, and every time database is updated run function to convert unstored variable to string
Method 2 (code below)
- Converter
Image:
@Converter
public class QueueConverter implements AttributeConverter<Queue, String> {
private static final ObjectMapper objectMapper = new ObjectMapper();
@Override
public String convertToDatabaseColumn(Queue queue) {
try {
return objectMapper.writeValueAsString(queue);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException("Error converting Queue to JSON", e);
}
}
@Override
public Queue convertToEntityAttribute(String dbData) {
try {
return objectMapper.readValue(dbData, Queue.class);
} catch (JsonProcessingException e) {
throw new IllegalArgumentException("Error converting JSON to Queue", e);
}
}
}
Had to think about existing code…
Current user database is situated somewhere else, not on our backend. Therefore, I had to create the function separately with an async function so that this can be substituted later for a fetch from the existing user database. Everything else works independently of this.
async function fetchPeople() {
const response = await fetch('http://localhost:8085/api/people');
if (response.ok) {
const people = await response.json();
return people.map(person => person.name);
}
return [];
}
Comments
You are seeing this because your Disqus shortname is not properly set. To configure Disqus, you should edit your
_config.yml
to include either adisqus.shortname
variable.If you do not wish to use Disqus, override the
comments.html
partial for this theme.