The TIBCO Platform is a real-time, composable data platform that will bring together an evolving set of your TIBCO solutions - and it's available now!
A chart showing the TIBCO Platform vision
Jump to content
Forums
Ask questions and gain insight from discussions

Recommended Posts

Posted

This is SDK connector to communicate with Sharepoint.

An item with the same key has already been added.

having the issue sometime when loading the fields of the entity.

 

 

I have debugged the code and check the duplicate name of fields and definition but nothing seems to be wrong.

 

RetrieveObjectDefinition method (To get the fields for the selected entity) calls many time for one particular connection, not for others.

 

 

Is there any way to see detail description of this issue in agent folder logs where I can find out that duplicate key name

Posted

Hey Ankit,

Object names cannot be duplicated across the connection and property names cannot be duplicated in an object. This happens commonly when:

 

 

You dynamically generate metadata, you might have duplicate objects or properties.

You are building hierarchal objects, and a nested object has the same name (e.g. VirtualAttachmentFolder and VirtualDocumentFolder each reference their own child object named Attachment).

 

 

I don't think there is logging for this already, but you could write your own. Here is one example:

https://gitlab.com/ScribeSoftware/sample-scribe-platform-api-connector/b...

 

Thanks,

Nate

Posted

Hi Nate,

 

Thanks for answered.

 

I'm sure there is no duplicate objects and properties. I have used GUID (that be generated at run time) as prefix of object and properties name but still same.

Don't consider the nested/ hierarchical objects.

The source code is not throwing any exceptions .

Posted

Our connector architect has provided the following code snippet that you could run to validate.

 

How to use (Given an IMetadataProvider mp)

 

Snippet:

 

mp.ValidateDuplicates();

 

The code is as follows (not tested, nor cleaned up, but should be close)

 

namespace MetadataDuplicateValidator

{

using Scribe.Core.ConnectorApi;

using System;

using System.Collections.Generic;

using System.Linq;

public static class MetadataValidatorEx

{

public static void ValidateDuplicates(this IMetadataProvider mp)

{

var duplicateActions = GetDuplicateActions(mp);

var objNames = mp.RetrieveObjectDefinitions().Select(x => x.FullName).ToList();

var duplicateObjs = GetDuplicateObjectNames(objNames);

var duplicateProperties = GetDuplicatePropertyNames(mp, objNames);

if (duplicateActions.Count == 0 &&

duplicateObjs.Count == 0 &&

duplicateProperties.Count == 0) { return; }

var actions = FormatActions(duplicateActions);

var objs = FormatObjs(duplicateObjs);

var props = FormatProps(duplicateProperties);

var nl = System.Environment.NewLine;

throw new ApplicationException($"{actions}{nl}{objs}{nl}{props}{nl}");

}

private static string MkList(IEnumerable ss)

{

return string.Join(", ", ss);

}

private static string FormatActions(IList x)

{

return x.Count == 0

"No Duplicate ActionDefinition FullNames."

: $"The following Actions were duplicates: {MkList(x)}.";

}

private static string FormatObjs(IList x)

{

return x.Count == 0

"No Duplicate ObjectDefinition names."

: $"The following ObjectDefinitions were duplicates: {MkList(x)}.";

}

private static string FormatProps(IList x)

{

return x.Count == 0

"No Duplicate PropertyDefinition FullNames."

: $"The following PropertyDefinitions were duplicates: {MkList(x)}.";

}

private static IList GetDuplicateObjectNames(List objs)

{

var duplicateObjNames = new List();

var objNames = new List();

foreach (var objName in objs)

{

if (objNames.Contains(objName)) { duplicateObjNames.Add(objName); }

objNames.Add(objName);

}

return duplicateObjNames;

}

private static IList GetDuplicatePropertyNames(IMetadataProvider mp, IList objs)

{

return objs.SelectMany(x => GetDuplicatePropertyNames(mp, x)).ToList();

}

private static IList GetDuplicatePropertyNames(IMetadataProvider mp, string objName)

{

var objDef = mp.RetrieveObjectDefinition(objName, true);

var listOfNames = new List();

var duplicates = new List();

foreach (var prop in objDef.PropertyDefinitions.Select(x => x.FullName))

{

if (listOfNames.Contains(prop))

{

duplicates.Add($"ObjFullName: {objName}, PropFullName: {prop}");

}

listOfNames.Add(prop);

}

return duplicates;

}

private static IList GetDuplicateActions(IMetadataProvider mp)

{

var actions = mp.RetrieveActionDefinitions().Select(x => x.FullName).ToList();

var duplicateActions = new List();

var actionNames = new List();

foreach (var action in actions)

{

if (actionNames.Contains(action)) { duplicateActions.Add(action); }

actionNames.Add(action);

}

return duplicateActions;

}

}

}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...