Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
joniles committed Dec 12, 2024
1 parent 111549f commit 9e0b47c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/main/java/net/sf/mpxj/ProjectCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,22 @@ private ProjectCode(Builder builder)
return m_values.stream().filter(v -> v.getParentValue() == null).collect(Collectors.toList());
}

/**
* Add value to this code.
*
* @param value new value
*/
public void addValue(ProjectCodeValue value)
{
m_values.add(value);
}

/**
* Retrieve a value by unique ID.
*
* @param id unique ID
* @return value or null
*/
public ProjectCodeValue getValueByUniqueID(Integer id)
{
if (id == null)
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/sf/mpxj/ResourceCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,22 @@ private ResourceCode(Builder builder)
return m_values.stream().filter(v -> v.getParentValue() == null).collect(Collectors.toList());
}

/**
* Add value to this code.
*
* @param value new value
*/
public void addValue(ResourceCodeValue value)
{
m_values.add(value);
}

/**
* Retrieve a value by unique ID.
*
* @param id unique ID
* @return value or null
*/
public ResourceCodeValue getValueByUniqueID(Integer id)
{
if (id == null)
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/sf/mpxj/RoleCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,22 @@ private RoleCode(Builder builder)
return m_values.stream().filter(v -> v.getParentValue() == null).collect(Collectors.toList());
}

/**
* Add value to this code.
*
* @param value new value
*/
public void addValue(RoleCodeValue value)
{
m_values.add(value);
}

/**
* Retrieve a value by unique ID.
*
* @param id unique ID
* @return value or null
*/
public RoleCodeValue getValueByUniqueID(Integer id)
{
if (id == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ private void addActivityCodes(MpxjTreeNode parentNode)
* Add codes to the tree.
*
* @param parentNode parent tree node
* @param codes list of codes
*/
private void addCodes(MpxjTreeNode parentNode, List<? extends Code> codes)
{
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/net/sf/mpxj/json/JsonWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,11 @@ private void writeActivityCodes() throws IOException

/**
* Write a list of codes.
*
* @param attributeName attribute name
* @param codes list of codes
*/
private void writeCodes(String label, List<? extends Code> codes) throws IOException
private void writeCodes(String attributeName, List<? extends Code> codes) throws IOException
{
if (codes.isEmpty())
{
Expand All @@ -353,7 +356,7 @@ private void writeCodes(String label, List<? extends Code> codes) throws IOExcep

List<? extends Code> sortedCodeList = new ArrayList<>(codes);
sortedCodeList.sort(Comparator.comparing(Code::getName));
m_writer.writeStartList(label);
m_writer.writeStartList(attributeName);
for (Code code : sortedCodeList)
{
writeCode(code);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ private void processProjectCodeAssignments(List<CodeAssignmentType> codes)
/**
* Process resource code assignments.
*
* @param resource parent resource
* @param codes resource code assignments
*/
private void processResourceCodeAssignments(Resource resource, List<CodeAssignmentType> codes)
Expand All @@ -741,6 +742,7 @@ private void processResourceCodeAssignments(Resource resource, List<CodeAssignme
/**
* Process role code assignments.
*
* @param resource parent resource
* @param codes role code assignments
*/
private void processRoleCodeAssignments(Resource resource, List<CodeAssignmentType> codes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1914,13 +1914,14 @@ private void writeProjectCodeAssignment(List<CodeAssignmentType> assignments, Pr
{
CodeAssignmentType xml = m_factory.createCodeAssignmentType();
assignments.add(xml);
xml.setTypeObjectId(value.getProjectCodeUniqueID());
xml.setValueObjectId(value.getUniqueID());
xml.setTypeObjectId(NumberHelper.getInt(value.getProjectCodeUniqueID()));
xml.setValueObjectId(NumberHelper.getInt(value.getUniqueID()));
}

/**
* Write resource code assignments.
*
* @param resource parent resource
* @param assignments resource code assignments
*/
private void writeResourceCodeAssignments(Resource resource, List<CodeAssignmentType> assignments)
Expand All @@ -1938,8 +1939,8 @@ private void writeResourceCodeAssignment(List<CodeAssignmentType> assignments, R
{
CodeAssignmentType xml = m_factory.createCodeAssignmentType();
assignments.add(xml);
xml.setTypeObjectId(value.getResourceCodeUniqueID());
xml.setValueObjectId(value.getUniqueID());
xml.setTypeObjectId(NumberHelper.getInt(value.getResourceCodeUniqueID()));
xml.setValueObjectId(NumberHelper.getInt(value.getUniqueID()));
}

/**
Expand Down

0 comments on commit 9e0b47c

Please sign in to comment.