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