Exemple #1
0
        public static Schema BuildSchema(Connector connector,
            GetSupportedObjectClassesDelegate getSupportedObjectClassesDelegate,
            GetObjectClassInfoDelegate getObjectClassInfoDelegate,
            GetSupportedOperationsDelegate getSupportedOperationsDelegate,
            GetUnSupportedOperationsDelegate getUnSupportedOperationsDelegate)
        {
            SchemaBuilder schemaBuilder = new SchemaBuilder(SafeType<Connector>.Get(connector));

            //iterate through supported object classes
            foreach (ObjectClass oc in getSupportedObjectClassesDelegate()) {
                ObjectClassInfo ocInfo = getObjectClassInfoDelegate(oc);
                Assertions.NullCheck(ocInfo, "ocInfo");

                //add object class to schema
                schemaBuilder.DefineObjectClass(ocInfo);

                //add supported operations
                IList<SafeType<SPIOperation>> supportedOps = getSupportedOperationsDelegate(oc);
                if (supportedOps != null) {
                    foreach (SafeType<SPIOperation> op in supportedOps) {
                        schemaBuilder.AddSupportedObjectClass(op, ocInfo);
                    }
                }

                //remove unsupported operatons
                IList<SafeType<SPIOperation>> unSupportedOps = getUnSupportedOperationsDelegate(oc);
                if (unSupportedOps != null) {
                    foreach (SafeType<SPIOperation> op in unSupportedOps) {
                        schemaBuilder.RemoveSupportedObjectClass(op, ocInfo);
                    }
                }
            }
            LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Finished retrieving schema");
            return schemaBuilder.Build();
        }
Exemple #2
0
        public static IDictionary<ObjectClass, ICollection<string>> GetAttributesReturnedByDefault(
            GetSupportedObjectClassesDelegate getSupportedObjectClassesDelegate,
            GetObjectClassInfoDelegate getObjectClassInfoDelegate)
        {
            var attributesReturnedByDefault = new Dictionary<ObjectClass, ICollection<string>>();

            //iterate through supported object classes
            foreach (ObjectClass oc in getSupportedObjectClassesDelegate()) {
                ObjectClassInfo ocInfo = getObjectClassInfoDelegate(oc);
                Assertions.NullCheck(ocInfo, "ocInfo");

                //populate the list of default attributes to get
                attributesReturnedByDefault.Add(oc, new HashSet<string>());
                foreach (ConnectorAttributeInfo caInfo in ocInfo.ConnectorAttributeInfos) {
                    if (caInfo.IsReturnedByDefault) {
                        attributesReturnedByDefault[oc].Add(caInfo.Name);
                    }
                }
            }
            return attributesReturnedByDefault;
        }
Exemple #3
0
        public static Schema BuildSchema(Connector connector,
                                         GetSupportedObjectClassesDelegate getSupportedObjectClassesDelegate,
                                         GetObjectClassInfoDelegate getObjectClassInfoDelegate,
                                         GetSupportedOperationsDelegate getSupportedOperationsDelegate,
                                         GetUnSupportedOperationsDelegate getUnSupportedOperationsDelegate)
        {
            SchemaBuilder schemaBuilder = new SchemaBuilder(SafeType <Connector> .Get(connector));

            //iterate through supported object classes
            foreach (ObjectClass oc in getSupportedObjectClassesDelegate())
            {
                ObjectClassInfo ocInfo = getObjectClassInfoDelegate(oc);
                Assertions.NullCheck(ocInfo, "ocInfo");

                //add object class to schema
                schemaBuilder.DefineObjectClass(ocInfo);

                //add supported operations
                IList <SafeType <SPIOperation> > supportedOps = getSupportedOperationsDelegate(oc);
                if (supportedOps != null)
                {
                    foreach (SafeType <SPIOperation> op in supportedOps)
                    {
                        schemaBuilder.AddSupportedObjectClass(op, ocInfo);
                    }
                }

                //remove unsupported operatons
                IList <SafeType <SPIOperation> > unSupportedOps = getUnSupportedOperationsDelegate(oc);
                if (unSupportedOps != null)
                {
                    foreach (SafeType <SPIOperation> op in unSupportedOps)
                    {
                        schemaBuilder.RemoveSupportedObjectClass(op, ocInfo);
                    }
                }
            }
            LOG.Debug("Finished retrieving schema");
            return(schemaBuilder.Build());
        }
Exemple #4
0
        public static IDictionary <ObjectClass, ICollection <string> > GetAttributesReturnedByDefault(
            GetSupportedObjectClassesDelegate getSupportedObjectClassesDelegate,
            GetObjectClassInfoDelegate getObjectClassInfoDelegate)
        {
            var attributesReturnedByDefault = new Dictionary <ObjectClass, ICollection <string> >();

            //iterate through supported object classes
            foreach (ObjectClass oc in getSupportedObjectClassesDelegate())
            {
                ObjectClassInfo ocInfo = getObjectClassInfoDelegate(oc);
                Assertions.NullCheck(ocInfo, "ocInfo");

                //populate the list of default attributes to get
                attributesReturnedByDefault.Add(oc, new HashSet <string>());
                foreach (ConnectorAttributeInfo caInfo in ocInfo.ConnectorAttributeInfos)
                {
                    if (caInfo.IsReturnedByDefault)
                    {
                        attributesReturnedByDefault[oc].Add(caInfo.Name);
                    }
                }
            }
            return(attributesReturnedByDefault);
        }