How can I get the number of contents of a dm_document? - documentum

I am trying to add a new content to my dm_document with the DFCMethod :
myDocument.setContentEx(myByteArrayOutpuStream, myContentExtension, pageNumber)
However, when I add this content, I don't know if there are other contents already added to this dm_document object. In other words, I don't know the value of the pageNumber parameter. I did not find any method such as a getLastContentIndex to perform on my dm_document.
How can I know the value to give for the parameter ?

The method your are looking for is int getPageCount().
You can also get the main content format (content type) name by the method String getContentType().
Then you can use received values as parameters in a call of the ByteArrayInputStream getContentEx(String format, int pageNumber) metod which gets the document content from the repository for the given format and page number.
By the boolean setContentEx(ByteArrayOutputStream content, String format, int pageNumber) method of IDfSysObject you can set primary content as multiple pages. But all pages must be in the same format. If you try to use the method with a different format then it will overwrite the previous content.

Related

Jackson and Bean Validation: Deserialize empty String as null

I've a RESTeasy application using Jackson and Bean Validation. A POJO might loo like this:
public class Foo {
#Size(min = 2)
private String bar;
}
Bar is validated if the client sends the bar property. And es expected: If the client does not send the property nothing will be validated.
If the client sends an empty String I'll get a constraint violation. This may be correct but it's hard to control what the value of an empty input field really is. For instance in my angular application the field will not be present if the user did not enter anything. Once he enters and deletes something I'll have an empty String.
I thought I could configure Jacksons behavior via DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT but as answered here this is only working for POJOs not for Strings. The only ways I see is not using #Size or writing an own deserializer for Strings. Both doesn't seem to be good solutions. Anyone other ideas?
If you want to accept the empty string, you could use the #Pattern constraint matching also the empty string: #Pattern(regexp = "^$|(.){2}") or #Pattern(regexp = "^$|...
The alternative is to write your own custom constraint.

EA Script for Defined Tag Types

I would like to create an EA Script to configure (add/edit/delete) the Defined Tag Types (Settings > UML Types > Tagged Value Types) similar to what is done manually here.
I did not found any useful information about the object storing the Defined Tag Types. Any help?
This configuration is not available in EA's API. If you want to make changes to it programmatically, you'll have to manipulate the project database directly.
The "Tagged Value Types" are stored in the t_propertytypes table. Please note that tagged value types defined in an MDG Technology are not listed here, this table only contains those that are shown in the "UML Types" dialog.
Looks like that you can programmatically only read the Tagged Values and change their value. Apparently you cannot add/remove Tagged Values.
Here is a part of the corresponding API. To add/remove a tagged value, you have to go directly to the DB.
TaggedValue Methods:
Method
Type
Notes
GetAttribute(string propName)
String
Returns the text of a single named property within a structured Tagged Value.
Parameters:
· propName: String - the name of the property for which the text is being returned
GetLastError()
String
Returns a string value describing the most recent error that occurred in relation to this object.
HasAttributes()
Boolean
Returns true if the Tagged Value is a structured Tagged Value with one or more properties.
SetAttribute(
string propName,
string propValue)
Boolean
Sets the text of a single named property within a structured Tagged Value.
Parameters:
· propName: String - - the name of the property for which the text is being set
· propValue: the value of the property
Update()
Boolean
Updates the current TaggedValue object after modification or appending a new item.
If false is returned, check the GetLastError function for more information.

RavenDB .Include() not working with int ids

RavenDB used to not accept Includes when the id fields were ints instead of strings.
But the documentation does not mention this limitation.
Is there any workaround that does not require changing the ids from int to strings in the .Net object model.
If you have a property that contains just the integer id of a related document, you can do this:
session.Include<User, Item>( user => user.ItemId).Load(1);
This will load users/1 and then get the value inside that user's ItemId and use the "items/" prefix to load the related item.

Is it possible to override the vb.net Resource Manager GetString function?

In the auto-generated resource designer file, there are properties for each resource. The property calls "GetString" which returns the string value. I would like to override this getstring function so I can do logic to see if I need to retrieve this value or a different value. I can't figure out how to do this because the designer file is auto-generated.
Public ReadOnly Property General() As String
Get
Return ResourceManager.GetString("General", resourceCulture)
End Get
End Property
For example, in my version of the GetString function, I would check the key passed in ("General") and see if there is a custom value for this key in a database. If the custom value exists, I would use that value. If the custom value does not exist, I would call the base GetString function to get the Resource value. I'd like to use the built in Resource class for this because then in my code I can just use "#Resources.General" and take advantage of the auto-complete functionality that already exists.
Refer to ASP.NET Resourcemanager to read local .resx. It's in C# but you can just convert it over. It isn't 100% of what you are looking for but shows a way of overriding in which you may be able to adjust to work with your needs.

override linq properties

I am using Linq to Sql that generated a data contract for a table. I have a date field in that table which is a non-nullable field. I need to override the auto generated property of the date field to return a specific value, something like
Get
if_dt<>date.minvalue
return _dt
else
return string.empty
End Get
Is it possible to override an autogenerated property in the designer.vb file using a partial class? I dont want to create a new property as it is currently being accessed in n number of places and I dont want to change it in every place.
No, you'll need to modify the .designer file or inherit from it and change the behavior of that property (but I guess the auto-generated property won't be virtual so you'll need to edit it anyway)