Skip to content

Commit

Permalink
Improve activity code method naming (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
joniles authored Dec 10, 2024
1 parent e8d8cfc commit e1dec38
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<action dev="joniles" type="update">Added the methods `Task.getPrimaryResource()` and `Task.setPrimaryResource()`.</action>
<action dev="joniles" type="update">Improved accuracy of retrieving the resource assignment GUID attribute when reading MPP files (Contributed by Fabian Schmidt).</action>
<action dev="joniles" type="update">Improve population of Task Start and Finish attributes when reading Primavera P6 schedules.</action>
<action dev="joniles" type="update">Marked the `ActivityCodeValue.getParent()` method as deprecated. Use `ActivityCodeValue.getParentValue()` instead.</action>
<action dev="joniles" type="update">Marked the `ActivityCodeValue.getParentUniqueID()` method as deprecated. Use `ActivityCodeValue.getParentValueUniqueID()` instead.</action>
<action dev="joniles" type="update">Marked the `ActivityCodeValue.Builder.parent()` method as deprecated. Use `ActivityCodeValue.Builder.parentValue()` instead.</action>
</release>
<release date="2024-11-25" version="13.7.0">
<action dev="joniles" type="update">Update the MPXJ ruby gem to allow access to calendar data.</action>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/sf/mpxj/ActivityCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public List<ActivityCodeValue> getValues()
*/
public List<ActivityCodeValue> getChildValues()
{
return m_values.stream().filter(v -> v.getParent() == null).collect(Collectors.toList());
return m_values.stream().filter(v -> v.getParentValue() == null).collect(Collectors.toList());
}

/**
Expand Down
57 changes: 46 additions & 11 deletions src/main/java/net/sf/mpxj/ActivityCodeValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private ActivityCodeValue(Builder builder)
m_name = builder.m_name;
m_description = builder.m_description;
m_color = builder.m_color;
m_parent = builder.m_parent;
m_parentValue = builder.m_parentValue;
}

/**
Expand Down Expand Up @@ -123,20 +123,42 @@ public Color getColor()
* Retrieve the parent ActivityCodeValue.
*
* @return parent ActivityCodeValue
* @deprecated use getParentValue
*/
public ActivityCodeValue getParent()
@Deprecated public ActivityCodeValue getParent()
{
return m_parent;
return m_parentValue;
}

/**
* Retrieve the parent ActivityCodeValue.
*
* @return parent ActivityCodeValue
*/
public ActivityCodeValue getParentValue()
{
return m_parentValue;
}

/**
* Retrieve the parent ActivityCodeValue unique ID.
*
* @return parent ActivityCodeValue unique ID
* @deprecated use getParentValueUniqueID
*/
@Deprecated public Integer getParentUniqueID()
{
return m_parentValue == null ? null : m_parentValue.getUniqueID();
}

/**
* Retrieve the parent ActivityCodeValue unique ID.
*
* @return parent ActivityCodeValue unique ID
*/
public Integer getParentUniqueID()
public Integer getParentValueUniqueID()
{
return m_parent == null ? null : m_parent.getUniqueID();
return m_parentValue == null ? null : m_parentValue.getUniqueID();
}

/**
Expand All @@ -146,7 +168,7 @@ public Integer getParentUniqueID()
*/
public List<ActivityCodeValue> getChildValues()
{
return m_activityCode.getValues().stream().filter(a -> a.m_parent == this).collect(Collectors.toList());
return m_activityCode.getValues().stream().filter(a -> a.m_parentValue == this).collect(Collectors.toList());
}

@Override public String toString()
Expand All @@ -160,7 +182,7 @@ public List<ActivityCodeValue> getChildValues()
private final String m_name;
private final String m_description;
private final Color m_color;
private final ActivityCodeValue m_parent;
private final ActivityCodeValue m_parentValue;

/**
* ActivityCodeValue builder.
Expand Down Expand Up @@ -191,7 +213,7 @@ public Builder from(ActivityCodeValue value)
m_name = value.m_name;
m_description = value.m_description;
m_color = value.m_color;
m_parent = value.m_parent;
m_parentValue = value.m_parentValue;
return this;
}

Expand Down Expand Up @@ -280,15 +302,28 @@ public Builder color(Color value)
return this;
}

/**
* Add parent value.
*
* @param value parent value
* @return builder
* @deprecated use parentValue
*/
@Deprecated public Builder parent(ActivityCodeValue value)
{
m_parentValue = value;
return this;
}

/**
* Add parent value.
*
* @param value parent value
* @return builder
*/
public Builder parent(ActivityCodeValue value)
public Builder parentValue(ActivityCodeValue value)
{
m_parent = value;
m_parentValue = value;
return this;
}

Expand All @@ -309,6 +344,6 @@ public ActivityCodeValue build()
private String m_name;
private String m_description;
private Color m_color;
private ActivityCodeValue m_parent;
private ActivityCodeValue m_parentValue;
}
}
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 @@ -2244,7 +2244,7 @@ public void processCodeLibraries(List<Row> types, List<Row> typeValues, List<Row
.sequenceNumber(sequence.getNext())
.name(name)
.description(description)
.parent(valueMap.get(row.getInteger("CODE_LIBRARY_ENTRY")))
.parentValue(valueMap.get(row.getInteger("CODE_LIBRARY_ENTRY")))
.build();
code.addValue(value);
valueMap.put(value.getUniqueID(), value);
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/net/sf/mpxj/json/JsonWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1551,10 +1551,9 @@ private void writeActivityCodeValue(ActivityCodeValue value) throws IOException
writeStringField("name", value.getName());
writeStringField("description", value.getDescription());
writeColorField("color", value.getColor());
if (value.getParent() != null)
{
writeIntegerField("parent_unique_id", value.getParent().getUniqueID());
}
// Deprecated
writeIntegerField("parent_unique_id", value.getParentValueUniqueID());
writeIntegerField("parent_value_unique_id", value.getParentValueUniqueID());
m_writer.writeEndObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ private void processActivityCodeDefinitions(List<ActivityCodeTypeType> types, Li
.name(typeValue.getCodeValue())
.description(typeValue.getDescription())
.color(ColorHelper.parseHtmlColor(typeValue.getColor()))
.parent(code.getValueByUniqueID(typeValue.getParentObjectId()))
.parentValue(code.getValueByUniqueID(typeValue.getParentObjectId()))
.build();
code.addValue(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 @@ -388,7 +388,7 @@ public void processActivityCodeDefinitions(List<Row> types, List<Row> typeValues
.name(row.getString("short_name"))
.description(row.getString("actv_code_name"))
.color(ColorHelper.parseHexColor(row.getString("color")))
.parent(code.getValueByUniqueID(row.getInteger("parent_actv_code_id")))
.parentValue(code.getValueByUniqueID(row.getInteger("parent_actv_code_id")))
.build();
code.addValue(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ interface ExportFunction<T>
static
{
ACTIVITY_CODE_VALUE_COLUMNS.put("actv_code_id", a -> a.getUniqueID());
ACTIVITY_CODE_VALUE_COLUMNS.put("parent_actv_code_id", a -> a.getParentUniqueID());
ACTIVITY_CODE_VALUE_COLUMNS.put("parent_actv_code_id", a -> a.getParentValueUniqueID());
ACTIVITY_CODE_VALUE_COLUMNS.put("actv_code_type_id", a -> a.getActivityCode().getUniqueID());
ACTIVITY_CODE_VALUE_COLUMNS.put("actv_code_name", a -> StringHelper.stripControlCharacters(a.getDescription()));
ACTIVITY_CODE_VALUE_COLUMNS.put("short_name", a -> StringHelper.stripControlCharacters(a.getName()));
Expand Down

0 comments on commit e1dec38

Please sign in to comment.