Skip to content

Commit

Permalink
Add activity code value method (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
joniles authored Aug 12, 2024
1 parent cb6b728 commit be61e2d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<action dev="joniles" type="update">Marked the `UserDefinedField` constructor as deprecated. Use the builder class instead.</action>
<action dev="joniles" type="update">Marked the `UserDefinedField.setDataType()` method as deprecated. Use the builder class instead.</action>
<action dev="joniles" type="update">Updated to address an issue when writing XER files where a project does not have an explicit Unique ID value, and there are project UDF values.</action>
<action dev="joniles" type="update">Added the convenience method `ActivityCode.addValue` to make it easier to add a value to an activity code.</action>
</release>
<release date="2024-07-26" version="13.1.0">
<action dev="joniles" type="update">Updated to POI 5.3.0</action>
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/net/sf/mpxj/ActivityCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ public List<ActivityCodeValue> getChildValues()
return m_values.stream().filter(v -> v.getParent() == null).collect(Collectors.toList());
}

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

private final Integer m_uniqueID;
private final ActivityCodeScope m_scope;
private final Integer m_scopeEpsUniqueID;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/mpxj/asta/AstaReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,7 @@ public void processCodeLibraries(List<Row> types, List<Row> typeValues, List<Row
.description(description)
.parent(valueMap.get(row.getInteger("CODE_LIBRARY_ENTRY")))
.build();
code.getValues().add(value);
code.addValue(value);
valueMap.put(value.getUniqueID(), value);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/mpxj/openplan/ActivityCodeReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void read(Map<String, Code> map)
{
ActivityCodeValue acv = new ActivityCodeValue.Builder(m_file).type(ac).name(value.getID()).description(value.getDescription()).sequenceNumber(Integer.valueOf(valueSequence++)).build();

ac.getValues().add(acv);
ac.addValue(acv);
valueMap.put(value.getUniqueID(), acv);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/mpxj/phoenix/Phoenix4Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private void readActivityCode(Code code, Integer activityCodeSequence)
.name(typeValue.getName())
.description(typeValue.getName())
.build();
activityCode.getValues().add(activityCodeValue);
activityCode.addValue(activityCodeValue);

String name = typeValue.getName();
UUID uuid = getValueUUID(codeUUID, typeValue.getUuid(), name);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/mpxj/phoenix/Phoenix5Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private void readActivityCode(Code code, Integer activityCodeSequence)
.name(typeValue.getName())
.description(typeValue.getName())
.build();
activityCode.getValues().add(activityCodeValue);
activityCode.addValue(activityCodeValue);

String name = typeValue.getName();
UUID uuid = getValueUUID(codeUUID, typeValue.getUuid(), name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ private void processActivityCodes(APIBusinessObjects apibo, List<ActivityCodeTyp
.color(ColorHelper.parseHtmlColor(typeValue.getColor()))
.parent(m_activityCodeMap.get(typeValue.getParentObjectId()))
.build();
code.getValues().add(value);
code.addValue(value);
m_activityCodeMap.put(value.getUniqueID(), value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/mpxj/primavera/PrimaveraReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public void processActivityCodes(List<Row> types, List<Row> typeValues, List<Row
.color(ColorHelper.parseHexColor(row.getString("color")))
.parent(m_activityCodeMap.get(row.getInteger("parent_actv_code_id")))
.build();
code.getValues().add(value);
code.addValue(value);
m_activityCodeMap.put(value.getUniqueID(), value);
}
}
Expand Down

0 comments on commit be61e2d

Please sign in to comment.