Aspose.Tasks for C++
ExtendedAttribute.h
1 #pragma once
2 //-----------------------------------------------------------------------
3 // <copyright file="ExtendedAttribute.cs" company="Aspose Pty Ltd">
4 // Copyright (c) 2002-2024 Aspose Pty Ltd. All Rights Reserved.
5 // </copyright>
6 //-----------------------------------------------------------------------
7 
8 #include <system/string.h>
9 #include <system/decimal.h>
10 #include <system/date_time.h>
11 
12 #include "aspose.tasks.cpp/Duration.h"
13 #include "aspose.tasks.cpp/aspose_tasks_api_defs.h"
14 
15 namespace Aspose
16 {
17 namespace Tasks
18 {
19 namespace Connectivity
20 {
21 template <typename> class MpdField;
22 class MspExtendedAttribute;
23 class MspTaskExtendedAttributeReader;
24 } // namespace Connectivity
25 enum class CustomFieldType;
26 class ExtendedAttributeCollection;
27 class ExtendedAttributeDefinition;
28 namespace Filters
29 {
30 class ExtendedAttributeIdFilter;
31 } // namespace Filters
32 class FormulaCalculator;
33 class FormulaOperatorToken;
34 class FormulaRelationalOperator;
35 class IExtendedAttributeParent;
36 namespace IO
37 {
38 namespace Html
39 {
40 class HtmlReadingUtils;
41 } // namespace Html
42 namespace Mpx
43 {
44 class MpxUtils;
45 } // namespace Mpx
46 namespace MSProject
47 {
48 class CustomFieldTypeReader;
49 class ExtendedAttributeValueConverter;
50 class MPP12AssignmentExtendedAttributeReader;
51 class MPP12AssignmentExtendedAttributeWriter;
52 class MPP12ExtendedAttributeWriter;
53 class MPP12ResourceWriter;
54 class MPP12TaskWriter;
55 class MPP14ResourceWriter;
56 class MPP14TaskWriter;
57 class MPP9AssignmentExtendedAttributeWriter;
58 class MPP9ResourceWriter;
59 class MPPAssignmentExtendedAttributeReader;
60 class MPPAssignmentExtendedAttributeWriter;
61 class MPPExtendedAttributeReader;
62 namespace Writers
63 {
64 class MPP9TaskWriter;
65 } // namespace Writers
66 } // namespace MSProject
67 namespace Pwa
68 {
69 namespace InternalApi
70 {
71 class CustomFieldContainerWriter;
72 namespace Mapping
73 {
74 class ExtendedAttributeDefinitionToRawValuesMapper;
75 template <typename> class ExtendedAttributeParentEntityToRawValuesMapper;
76 template <typename> class ProjectCoreEntityMapperBase;
77 } // namespace Mapping
78 } // namespace InternalApi
79 } // namespace Pwa
80 namespace Xer
81 {
82 class PrimaveraExtendedAttributeBuilder;
83 } // namespace Xer
84 namespace Xml
85 {
86 class ExtendedAttributeFactory;
87 class ExtendedAttributeNodeReader;
88 class ExtendedAttributeNodeWriter;
89 class ResourceAssignmentNodeReader;
90 class ResourceAssignmentNodeWriter;
91 } // namespace Xml
92 } // namespace IO
93 class ProjectIntegrityValidator;
94 namespace Rollup
95 {
96 class AverageFirstSublevelRollupCalculator;
97 class AverageRollupCalculator;
98 class ChildrenCountFirstSublevelRollupCalculator;
99 class ChildrenCountNonSummariesRollupCalculator;
100 class ChildrenCountRollupCalculator;
101 class DurationExtendedAttributeComparer;
102 class MinMaxRollupCalculator;
103 template <typename> class RollupCalculatorBase;
104 class SumRollupCalculator;
105 } // namespace Rollup
106 namespace Saving
107 {
108 class HtmlUtils;
109 class MpxSavingUtils;
110 } // namespace Saving
111 namespace Util
112 {
113 class ExtendedAttributeChecker;
114 namespace Fields
115 {
116 class FieldHelperInternal;
117 } // namespace Fields
118 } // namespace Util
119 namespace Visualization
120 {
121 template <typename> class FieldToColumnText;
122 } // namespace Visualization
123 } // namespace Tasks
124 } // namespace Aspose
125 
126 namespace Aspose {
127 
128 namespace Tasks {
129 
130 /// <summary>
131 /// Represents extended attributes.
132 /// </summary>
133 /// <remarks>
134 /// Currently supported all types of Extended attributes reading from MSP Xml 2003/2007 and mpp 2003.
135 /// For MSP mpp 2007 all Extended attributes reading supported except durations and flags.
136 /// </remarks>
137 class ASPOSE_TASKS_SHARED_CLASS ExtendedAttribute : public System::Object
138 {
139  typedef ExtendedAttribute ThisType;
140  typedef System::Object BaseType;
141 
142  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
143  ASPOSE_TASKS_SHARED_RTTI_INFO_DECL();
144 
145  friend class Aspose::Tasks::Filters::ExtendedAttributeIdFilter;
146  friend class Aspose::Tasks::IO::Pwa::InternalApi::CustomFieldContainerWriter;
147  template<typename FT0> friend class Aspose::Tasks::IO::Pwa::InternalApi::Mapping::ExtendedAttributeParentEntityToRawValuesMapper;
148  friend class Aspose::Tasks::IO::Pwa::InternalApi::Mapping::ExtendedAttributeDefinitionToRawValuesMapper;
149  friend class Aspose::Tasks::IO::Xml::ExtendedAttributeFactory;
153  friend class Aspose::Tasks::FormulaCalculator;
154  friend class Aspose::Tasks::FormulaOperatorToken;
155  friend class Aspose::Tasks::FormulaRelationalOperator;
156  template<typename FT0> friend class Aspose::Tasks::Connectivity::MpdField;
157  friend class Aspose::Tasks::Connectivity::MspExtendedAttribute;
158  friend class Aspose::Tasks::Connectivity::MspTaskExtendedAttributeReader;
159  friend class Aspose::Tasks::IO::Html::HtmlReadingUtils;
160  friend class Aspose::Tasks::IO::MSProject::CustomFieldTypeReader;
161  friend class Aspose::Tasks::IO::MSProject::ExtendedAttributeValueConverter;
162  friend class Aspose::Tasks::IO::MSProject::MPP12AssignmentExtendedAttributeReader;
163  friend class Aspose::Tasks::IO::MSProject::MPPAssignmentExtendedAttributeReader;
164  friend class Aspose::Tasks::IO::MSProject::MPP12ResourceWriter;
165  friend class Aspose::Tasks::IO::MSProject::MPP9ResourceWriter;
166  friend class Aspose::Tasks::IO::MSProject::MPP14ResourceWriter;
167  friend class Aspose::Tasks::IO::MSProject::MPP14TaskWriter;
168  friend class Aspose::Tasks::IO::MSProject::MPPExtendedAttributeReader;
169  friend class Aspose::Tasks::IO::MSProject::MPP12AssignmentExtendedAttributeWriter;
170  friend class Aspose::Tasks::IO::MSProject::MPPAssignmentExtendedAttributeWriter;
171  friend class Aspose::Tasks::IO::MSProject::MPP12ExtendedAttributeWriter;
172  friend class Aspose::Tasks::IO::MSProject::MPP12TaskWriter;
173  friend class Aspose::Tasks::IO::MSProject::Writers::MPP9TaskWriter;
174  friend class Aspose::Tasks::IO::MSProject::MPP9AssignmentExtendedAttributeWriter;
175  friend class Aspose::Tasks::IO::Mpx::MpxUtils;
176  friend class Aspose::Tasks::IO::Xer::PrimaveraExtendedAttributeBuilder;
177  template<typename FT0> friend class Aspose::Tasks::IO::Pwa::InternalApi::Mapping::ProjectCoreEntityMapperBase;
178  friend class Aspose::Tasks::IO::Xml::ExtendedAttributeNodeReader;
179  friend class Aspose::Tasks::IO::Xml::ExtendedAttributeNodeWriter;
180  friend class Aspose::Tasks::IO::Xml::ResourceAssignmentNodeReader;
181  friend class Aspose::Tasks::IO::Xml::ResourceAssignmentNodeWriter;
182  friend class Aspose::Tasks::ProjectIntegrityValidator;
183  friend class Aspose::Tasks::Rollup::AverageFirstSublevelRollupCalculator;
184  friend class Aspose::Tasks::Rollup::AverageRollupCalculator;
185  friend class Aspose::Tasks::Rollup::ChildrenCountFirstSublevelRollupCalculator;
186  template<typename FT0> friend class Aspose::Tasks::Rollup::RollupCalculatorBase;
187  friend class Aspose::Tasks::Rollup::ChildrenCountNonSummariesRollupCalculator;
188  friend class Aspose::Tasks::Rollup::ChildrenCountRollupCalculator;
189  friend class Aspose::Tasks::Rollup::DurationExtendedAttributeComparer;
190  friend class Aspose::Tasks::Rollup::MinMaxRollupCalculator;
191  friend class Aspose::Tasks::Rollup::SumRollupCalculator;
192  friend class Aspose::Tasks::Saving::HtmlUtils;
193  friend class Aspose::Tasks::Saving::MpxSavingUtils;
194  friend class Aspose::Tasks::Util::ExtendedAttributeChecker;
195  friend class Aspose::Tasks::Util::Fields::FieldHelperInternal;
196  template<typename FT0> friend class Aspose::Tasks::Visualization::FieldToColumnText;
197 
198 public:
199 
200  /// <summary>
201  /// Gets the attribute definition.
202  /// </summary>
203  ASPOSE_TASKS_SHARED_API System::SharedPtr<ExtendedAttributeDefinition> get_AttributeDefinition() const;
204  /// <summary>
205  /// Gets the id of a field.
206  /// </summary>
207  ASPOSE_TASKS_SHARED_API System::String get_FieldId() const;
208  /// <summary>
209  /// Gets value for attributes with 'Duration' type.
210  /// </summary>
211  /// <exception cref="InvalidOperationException">Thrown if the <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not initialized or custom field type of <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not a <see cref="Duration"></see> instance.</exception>
212  ASPOSE_TASKS_SHARED_API Duration get_DurationValue();
213  /// <summary>
214  /// Sets value for attributes with 'Duration' type.
215  /// </summary>
216  /// <exception cref="InvalidOperationException">Thrown if the <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not initialized or custom field type of <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not a <see cref="Duration"></see> instance.</exception>
217  ASPOSE_TASKS_SHARED_API void set_DurationValue(Duration value);
218  /// <summary>
219  /// Gets a value for attributes with numeric types (Cost, Number).
220  /// </summary>
221  /// <exception cref="InvalidOperationException">Thrown if the <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not initialized or custom field type of <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not 'Cost' or 'Number'.</exception>
222  ASPOSE_TASKS_SHARED_API System::Decimal get_NumericValue();
223  /// <summary>
224  /// Sets a value for attributes with numeric types (Cost, Number).
225  /// </summary>
226  /// <exception cref="InvalidOperationException">Thrown if the <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not initialized or custom field type of <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not 'Cost' or 'Number'.</exception>
227  ASPOSE_TASKS_SHARED_API void set_NumericValue(System::Decimal value);
228  /// <summary>
229  /// Gets a value for attributes with date types (Date, Start, Finish).
230  /// </summary>
231  /// <exception cref="InvalidOperationException">Thrown if the <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not initialized or current attribute is not an date attribute.</exception>
232  ASPOSE_TASKS_SHARED_API System::DateTime get_DateValue();
233  /// <summary>
234  /// Sets a value for attributes with date types (Date, Start, Finish).
235  /// </summary>
236  /// <exception cref="InvalidOperationException">Thrown if the <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not initialized or current attribute is not an date attribute.</exception>
237  ASPOSE_TASKS_SHARED_API void set_DateValue(System::DateTime value);
238  /// <summary>
239  /// Gets a value indicating whether a flag is set for an attribute with 'Flag' type.
240  /// </summary>
241  /// <exception cref="InvalidOperationException">Thrown if the <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not initialized or current attribute is not a flag attribute.</exception>
242  ASPOSE_TASKS_SHARED_API bool get_FlagValue();
243  /// <summary>
244  /// Sets a value indicating whether a flag is set for an attribute with 'Flag' type.
245  /// </summary>
246  /// <exception cref="InvalidOperationException">Thrown if the <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not initialized or current attribute is not a flag attribute.</exception>
247  ASPOSE_TASKS_SHARED_API void set_FlagValue(bool value);
248  /// <summary>
249  /// Gets a value for attributes with 'Text' type.
250  /// </summary>
251  /// <exception cref="InvalidOperationException">Thrown if the <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not initialized or current attribute is not a text attribute.</exception>
252  ASPOSE_TASKS_SHARED_API System::String get_TextValue();
253  /// <summary>
254  /// Sets a value for attributes with 'Text' type.
255  /// </summary>
256  /// <exception cref="InvalidOperationException">Thrown if the <see cref="ExtendedAttribute::AttributeDefinition"></see> property is not initialized or current attribute is not a text attribute.</exception>
257  ASPOSE_TASKS_SHARED_API void set_TextValue(const System::String& value);
258  /// <summary>
259  /// Gets the guid of a lookup value.
260  /// </summary>
261  /// <remarks>
262  /// Should not be set directly, instead use ExtendedAttributeDefinition.CreateExtendedAttribute(Value lookupValue) to create an extended attribute with a lookup value.
263  /// </remarks>
264  ASPOSE_TASKS_SHARED_API System::String get_ValueGuid() const;
265  /// <summary>
266  /// Gets a value indicating whether a value of this <see cref="ExtendedAttribute"></see> instance is read-only.
267  /// <value>returns true if a formula or rollup is defined in the <see cref="ExtendedAttributeDefinition"></see> for this object.</value>
268  /// </summary>
269  ASPOSE_TASKS_SHARED_API bool get_ValueReadOnly() const;
270  /// <summary>
271  /// Gets whether calculation of extended attribute's value resulted in an error.
272  /// </summary>
273  ASPOSE_TASKS_SHARED_API bool get_IsErrorValue();
274 
275  /// <summary>
276  /// Returns short string representation of an extended attribute.
277  /// </summary>
278  /// <returns>The string representation of the extended attribute.</returns>
279  ASPOSE_TASKS_SHARED_API System::String ToString() const override;
280 
281 protected:
282 
283  /// <summary>
284  /// Gets the attribute definition.
285  /// </summary>
286  ASPOSE_TASKS_SHARED_API void set_AttributeDefinition(const System::SharedPtr<ExtendedAttributeDefinition>& value);
287  /// <summary>
288  /// Gets the id of a field.
289  /// </summary>
290  ASPOSE_TASKS_SHARED_API void set_FieldId(const System::String& value);
291  /// <summary>
292  /// Gets the guid of a lookup value.
293  /// </summary>
294  /// <remarks>
295  /// Should not be set directly, instead use ExtendedAttributeDefinition.CreateExtendedAttribute(Value lookupValue) to create an extended attribute with a lookup value.
296  /// </remarks>
297  ASPOSE_TASKS_SHARED_API void set_ValueGuid(const System::String& value);
298  static ASPOSE_TASKS_SHARED_API System::SharedPtr<System::Object> get_ErrorValue();
299  /// <summary>
300  /// Legacy non-strongly typed extended attribute value.
301  /// </summary>
302  ASPOSE_TASKS_SHARED_API System::String get_Value();
303  /// <summary>
304  /// Legacy non-strongly typed extended attribute value.
305  /// </summary>
306  ASPOSE_TASKS_SHARED_API void set_Value(const System::String& value);
307  ASPOSE_TASKS_SHARED_API const System::SharedPtr<IExtendedAttributeParent>& get_Parent() const;
308  ASPOSE_TASKS_SHARED_API void set_Parent(const System::SharedPtr<IExtendedAttributeParent>& value);
309  ASPOSE_TASKS_SHARED_API int32_t get_ValueId() const;
310  ASPOSE_TASKS_SHARED_API void set_ValueId(int32_t value);
311  ASPOSE_TASKS_SHARED_API bool get_IsEmpty();
312  ASPOSE_TASKS_SHARED_API bool get_IsNumeric();
313 
314  /// <summary>
315  /// Initializes a new instance of the <see cref="ExtendedAttribute"></see> class.
316  /// </summary>
317  ASPOSE_TASKS_SHARED_API ExtendedAttribute();
318 
319  ASPOSE_TASKS_SHARED_API MEMBER_FUNCTION_MAKE_OBJECT_DECLARATION(ExtendedAttribute, CODEPORTING_ARGS());
320  ASPOSE_TASKS_SHARED_API void CopyValueFrom(const System::SharedPtr<ExtendedAttribute>& sourceAttribute);
321  ASPOSE_TASKS_SHARED_API void SetFromCalculatedValue(const System::SharedPtr<System::Object>& calculatedValue);
322  static ASPOSE_TASKS_SHARED_API bool IsValueError(const System::SharedPtr<System::Object>& val);
323  #ifdef ASPOSE_GET_SHARED_MEMBERS
324  ASPOSE_TASKS_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
325  #endif
326 
327 
328 private:
329 
330  static const System::String& ErrorValueDisplayText();
331  static System::SharedPtr<System::Object>& errorValue();
332 
333  mutable System::String value;
334  Duration durationValue;
335  System::Decimal numericValue;
336  System::DateTime dateValue;
337  bool flagValue;
338  System::SharedPtr<ExtendedAttributeDefinition> attributeDefinition;
339  System::String pr_FieldId;
340  System::String pr_ValueGuid;
341  System::WeakPtr<IExtendedAttributeParent> pr_Parent;
342  int32_t pr_ValueId;
343 
344  bool get_IsValueCalculated() const;
345  bool get_HasFormula() const;
346  bool get_HasRollup() const;
347 
348  System::String ToString_NonConst();
349  System::SharedPtr<System::Object> GetCalculatedValue() const;
350  System::String GetCalculatedStringValue(const System::SharedPtr<System::Object>& calculatedValue) const;
351  System::Decimal GetCalculatedValueAsDecimal(const System::SharedPtr<System::Object>& calculatedValue);
352  System::SharedPtr<System::Object> GetFormulaResult() const;
353  void CheckDefinitionAndAttributeProperty(CustomFieldType expectedFieldType);
354  void CheckDefinitionAndAttributeProperty(CustomFieldType expectedFieldType1, CustomFieldType expectedFieldType2);
355  void CheckDefinitionAndAttributeProperty(CustomFieldType expectedFieldType1, CustomFieldType expectedFieldType2, CustomFieldType expectedFieldType3);
356  void UpdateValues();
357  void UpdateValue();
358  System::Decimal ParseNumeric(const System::SharedPtr<System::Object>& val);
359  System::DateTime ParseDateTime(const System::SharedPtr<System::Object>& val);
360  Duration ParseDuration(const System::SharedPtr<System::Object>& val);
361  static System::String ValueAsString(const System::SharedPtr<System::Object>& calculatedValue);
362 
363 };
364 
365 } // namespace Tasks
366 } // namespace Aspose
367 
368 
Represents duration in a project.
Definition: Duration.h:163
Represents a collection of ExtendedAttribute objects.
Definition: ExtendedAttributeCollection.h:80
Represents an extended attribute definition associated with a project.
Definition: ExtendedAttributeDefinition.h:182
Represents extended attributes.
Definition: ExtendedAttribute.h:138
void set_NumericValue(System::Decimal value)
Sets a value for attributes with numeric types (Cost, Number).
System::String get_TextValue()
Gets a value for attributes with 'Text' type.
System::Decimal get_NumericValue()
Gets a value for attributes with numeric types (Cost, Number).
System::String get_ValueGuid() const
Gets the guid of a lookup value.
System::DateTime get_DateValue()
Gets a value for attributes with date types (Date, Start, Finish).
Duration get_DurationValue()
Gets value for attributes with 'Duration' type.
void set_FlagValue(bool value)
Sets a value indicating whether a flag is set for an attribute with 'Flag' type.
bool get_FlagValue()
Gets a value indicating whether a flag is set for an attribute with 'Flag' type.
System::String ToString() const override
Returns short string representation of an extended attribute.
bool get_ValueReadOnly() const
Gets a value indicating whether a value of this ExtendedAttribute instance is read-only....
System::SharedPtr< ExtendedAttributeDefinition > get_AttributeDefinition() const
Gets the attribute definition.
System::String get_FieldId() const
Gets the id of a field.
bool get_IsErrorValue()
Gets whether calculation of extended attribute's value resulted in an error.
void set_TextValue(const System::String &value)
Sets a value for attributes with 'Text' type.
void set_DurationValue(Duration value)
Sets value for attributes with 'Duration' type.
void set_DateValue(System::DateTime value)
Sets a value for attributes with date types (Date, Start, Finish).
Definition: Asn.h:13