This repository has been archived by the owner on Dec 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Students have phones too #40
Merged
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ef0c9b9
MUMPFL-113 Adds lastModified to TypeValue object
vertein a1e3684
MUMPFL-113 Adds EmergencyPhoneNumber interfaces
vertein 406faf1
MUMPFL-113 Adds MW Integration
vertein aee0d69
MUMFPL-113 adds ui for entering emergency phone
vertein cf27334
MUMPFL-113 Adds emergency phone directive
vertein 2ed342e
MUMPFL-113 Adds emergencyPhoneNumber local-impl
vertein 12fa48c
MUMPFL-113 Adds UI Polish to EmergencyPhoneNumber
vertein 95e72da
Refactors log.trace statements for readability
vertein 7468ca2
MUMPFL-113 Adds better description for console log
vertein 1da0204
MUMPFL-113 Adds accessibility resources
vertein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 23 additions & 0 deletions
23
my-profile-api/src/main/java/edu/wisc/my/profile/service/EmergencyPhoneNumberService.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,23 @@ | ||
package edu.wisc.my.profile.service; | ||
|
||
import edu.wisc.my.profile.model.TypeValue; | ||
|
||
public interface EmergencyPhoneNumberService{ | ||
|
||
/** | ||
* Gets a user's emergency Phone Numbers | ||
* @param netid the uid or net id of user | ||
* @return a TypeValue array representing the phone numbers | ||
*/ | ||
public TypeValue[] getEmergencyPhoneNumbers(String netid); | ||
|
||
/** | ||
* Sets the emergency phone number for a given user and returns the saved | ||
* phone numbers | ||
* @param phoneNumbers | ||
* @return the phones number of that individual | ||
* @throws Exception | ||
*/ | ||
public TypeValue[] setEmergencyPhoneNumbers(String netid, TypeValue[] phoneNumbers) throws Exception; | ||
|
||
} |
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
24 changes: 24 additions & 0 deletions
24
...rofile-middleware-impl/src/main/java/edu/wisc/my/profile/dao/EmergencyPhoneNumberDao.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,24 @@ | ||
package edu.wisc.my.profile.dao; | ||
|
||
import edu.wisc.my.profile.model.TypeValue; | ||
|
||
public interface EmergencyPhoneNumberDao { | ||
|
||
/** | ||
* Gets emergency phone numbers for user | ||
* @param netid | ||
* @return a TypeValue representing phone numbers | ||
*/ | ||
TypeValue[] getPhoneNumbers(String netId); | ||
|
||
|
||
/** | ||
* Sets emergency phone numbers returning the saved phone numbers | ||
* @param netid | ||
* @param phoneNumbers | ||
* @return the saved phone numbers | ||
* @throws Exception | ||
*/ | ||
TypeValue[] setPhoneNumbers(String netId, TypeValue[] phoneNumbers) throws Exception; | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
...le-middleware-impl/src/main/java/edu/wisc/my/profile/dao/EmergencyPhoneNumberDaoImpl.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,63 @@ | ||
package edu.wisc.my.profile.dao; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import org.joda.time.DateTime; | ||
import org.json.JSONObject; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
|
||
import edu.wisc.my.profile.mapper.ContactInformationMapper; | ||
import edu.wisc.my.profile.model.ContactInformation; | ||
import edu.wisc.my.profile.model.TypeValue; | ||
|
||
public class EmergencyPhoneNumberDaoImpl implements EmergencyPhoneNumberDao { | ||
|
||
protected final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
@Autowired | ||
private EmergencyContactMiddlewareDao ecdao; | ||
|
||
@Autowired | ||
private LocalContactMiddlewareDao lcdao; | ||
|
||
private JdbcTemplate jdbcTemplate; | ||
|
||
public EmergencyPhoneNumberDaoImpl(DataSource ds) { | ||
jdbcTemplate = new JdbcTemplate(ds); | ||
} | ||
|
||
@Override | ||
public TypeValue[] getPhoneNumbers(String netId) { | ||
TypeValue[] tv = jdbcTemplate.query("select PERSONPROFILE.PERSONPROFILE.GET_PERSON_PROFILE( ? ) from dual", new EmergencyPhoneNumberResultSetExtractor(), netId); | ||
return tv; | ||
} | ||
|
||
@Override | ||
public TypeValue[] setPhoneNumbers(String netId, TypeValue[] phoneNumbers) throws Exception { | ||
// Keep the hack alive as in EmergencyContactMiddleWareDaoImpl and LocalContactMiddlewareDaoImpl | ||
// Get the other info, add the new stuff and save the one object | ||
ContactInformation[] emergencyContacts = ecdao.getData(netId); | ||
ContactInformation localInfo = lcdao.getContactInfo(netId); | ||
TypeValue[] phNumberWithDate = phoneNumbers; | ||
for(TypeValue phoneNumber: phoneNumbers){ | ||
phoneNumber.setLastModified(DateTime.now()); | ||
} | ||
JSONObject json = ContactInformationMapper.convertToJSONObject(emergencyContacts, localInfo, phNumberWithDate); | ||
json.put("NETID", netId); | ||
if(logger.isTraceEnabled()) { | ||
logger.trace("Saving the following JSON: " + json.toString()); | ||
} | ||
String result = jdbcTemplate.query("select PERSONPROFILE.PERSONPROFILE.SAVE_PERSON_PROFILE( ? ) from dual", new MiddlewareUpdateExtractor(), json.toString()); | ||
|
||
if(MiddlewareUpdateExtractor.SUCCESS.equals(result)) { | ||
//return saved content | ||
return phoneNumbers; | ||
} else { | ||
throw new Exception("There was an issue saving the emergency contacts"); | ||
} | ||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...re-impl/src/main/java/edu/wisc/my/profile/dao/EmergencyPhoneNumberResultSetExtractor.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,36 @@ | ||
package edu.wisc.my.profile.dao; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
import org.json.JSONObject; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.dao.DataAccessException; | ||
import org.springframework.jdbc.core.ResultSetExtractor; | ||
|
||
import edu.wisc.my.profile.mapper.ContactInformationMapper; | ||
import edu.wisc.my.profile.model.TypeValue; | ||
|
||
public class EmergencyPhoneNumberResultSetExtractor implements ResultSetExtractor<TypeValue[]> { | ||
|
||
protected final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
@Override | ||
public TypeValue[] extractData(ResultSet rs) throws SQLException, DataAccessException { | ||
if(rs.next()) { | ||
String val = rs.getString(1); | ||
TypeValue[] value = null; | ||
try { | ||
JSONObject json = new JSONObject(val); | ||
value = ContactInformationMapper.convertToEmergencyPhoneNumber(json); | ||
return value; | ||
} catch (Exception e) { | ||
logger.error("Issue fetching user info",e); | ||
} | ||
} | ||
//error or empty | ||
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
25 changes: 25 additions & 0 deletions
25
...eware-impl/src/main/java/edu/wisc/my/profile/service/EmergencyPhoneNumberServiceImpl.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,25 @@ | ||
package edu.wisc.my.profile.service; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
import edu.wisc.my.profile.dao.EmergencyPhoneNumberDao; | ||
import edu.wisc.my.profile.model.TypeValue; | ||
|
||
@Service | ||
public class EmergencyPhoneNumberServiceImpl implements EmergencyPhoneNumberService { | ||
|
||
@Autowired | ||
private EmergencyPhoneNumberDao dao; | ||
|
||
@Override | ||
public TypeValue[] getEmergencyPhoneNumbers(String netId) { | ||
return dao.getPhoneNumbers(netId); | ||
} | ||
|
||
@Override | ||
public TypeValue[] setEmergencyPhoneNumbers(String netId, TypeValue[] phoneNumbers) throws Exception{ | ||
return dao.setPhoneNumbers(netId, phoneNumbers); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slf4j
enables a not-if
-gatedlogger.trace("Saving the following JSON: {} .", json);
at no meaningful performance penalty vs this syntax.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look. This was copy and pasted, so I might look at our other uses of this.