Conversion Integer to String - Forum - Corticon - Progress Community

Conversion Integer to String


Conversion Integer to String

This question has suggested answer(s)


I'm having in a Vocabulary a FieldData (to represent a Generic Output Element) with a entity "value", this one a String type.

In my vocabulary I have enumeration "TipusContracte", this one of type Integer.

I'm trying to output an element of this enumeration to FielData.value one element of "TipusContracte" enumeration.


When I'm trying to test it it gives me this error:

[javac]   required: String

    [javac]   found: Long

    [javac]   reason: actual argument Long cannot be converted to String by method invocation conversion

    [javac] U:\entorn\Progress\CorticonWork_5.6\STU\CcServerSandbox\DoNotDelete\Compilation\C16_1508321237327.138023\corticonrules_inmemory\ error: int cannot be dereferenced

    [javac] corticoncdo.DFomulari.DFormDefinition.IEFieldDataCDO new_Fomulari_FormDefinition_FieldData599475256 = new corticoncdo.DFomulari.DFormDefinition.EFieldDataCDO();aEngine.newEntity((com.corticon.cdo.CorticonBaseDataObject)new_Fomulari_FormDefinition_FieldData599475256,false);new_Fomulari_FormDefinition_FieldData599475256.setAvalueAttr(new Long(( 3 ).toString()));lobjFomulari_FormDefinition_Field.addRfieldDataAssoc(new_Fomulari_FormDefinition_FieldData599475256);aEngine.persistEntity((com.corticon.cdo.CorticonBaseDataObject)new_Fomulari_FormDefinition_FieldData599475256);addNew("corticoncdo.DFomulari.DFormDefinition.IEFieldDataCDO",new_Fomulari_FormDefinition_FieldData599475256);

It seems he tries to convert first to Long and then to String, its possible to give me an alternative?

I upload my projecte.

All Replies
  • Can you please clarify? What are you trying to achieve? Are you trying to store the "label" value from an integer enumeration custom data type into a string attribute? Or are you trying to catch the "value" from an integer enumeration custom data type, convert it to string and store it into a string attribute?

  • I'm trying to catche the "value" from an integer enumertaion and convert it to string attribute.

  • You could insert an extra rule action to accomplish this --> FieldData.Value = FieldData.intValue.toString

    It will iterate through your new FieldData collection and update the Value field with the string converted value you stored in the intValue attribute. I realise this is an extra step as you'll first need to store the interger value from your integer enumerated custom data type, and then use that value to get to a string value. But it works and is not much extra effort.

  • I don't think this is something that you can do with custom data types in Corticon. Custom Data Types are possible values linked to an attribute in the vocabulary, and for that attribute you limit possible values to the values listed in the custom data type. What you are trying to do here is conceptually use the values (or labels) as constants. This is not the intended use, and I would be surprised if you can assign (or test) a value of the cdt to a 'generic' string or integer.

    On a different note, to refer to specific values or labels in a cdt the . (dot) syntax is non-supported. You really should use the # notation (as in TipusContracte#AdministratiuEspecial).