public static bool IsOneToOne(Cardinality cardinality1, Cardinality cardinality2) { if (cardinality1 == One && cardinality2 == One) return true; return false; }
public static bool IsManyToMany(Cardinality cardinality1, Cardinality cardinality2) { if (cardinality1 == Many && cardinality2 == Many) return true; return false; }
public void SetCardinality(Cardinality cardinality) { if (this.Items.Count != 0) { throw new InvalidOperationException(); } this.Cardinality = cardinality; }
public InputGroup(string name, string preMessage, string postMessage, bool isPrompt, Cardinality cardinality) { this.Items = new HashSet<InputBase>(); this.Name = name; this.Cardinality = cardinality; this.PreMessage = preMessage; this.PostMessage = postMessage; this.IsPrompt = IsPrompt; }
public AtomSymbol(IEnumerable<Annotation> annotations, TypeLookup type, Cardinality cardinality, Identifier name) : base(type, cardinality) { Annotations = Guard.NotNull(annotations, "annotations") .GroupBy(x => x.Name) .ToDictionary(x => x.Key, x => new ReadOnlyCollection<Annotation>(x.ToList())) .ToReadOnlyDictionary(); Name = Guard.NotNull(name, "name"); }
public RunWorkPlan( DataSet dataSet, Cardinality cardinality, IndexType indexType, ReservationBufferSize reservationBufferSize, CacheSize cacheSize, Drive drive, CacheType cacheType, WorkPlan workPlan) : base(dataSet, cardinality, indexType, reservationBufferSize, cacheType, cacheSize) { Drive = drive; WorkPlan = workPlan; }
public static string CardinalityToString(Cardinality cardinality) { switch (cardinality) { case Cardinality.One: return "1"; case Cardinality.ZeroToOne: return "0..1"; case Cardinality.Many: return "*"; } throw new NotImplementedException(); }
public sxPropertyDefinition(IPropertyTemplate pt) { m_def = null; m_desc = null; m_temp = pt; m_id = m_temp.Id.ToString(); m_displayName = m_temp.DisplayName; m_name = m_temp.SymbolicName; m_cardinality = m_temp.Cardinality; m_choiceList = m_temp.ChoiceList; m_typeID = m_temp.DataType; m_hidden = m_temp.IsHidden; m_required = m_temp.IsValueRequired; }
public Experiment( DataSet dataSet, Cardinality cardinality, IndexType indexType, ReservationBufferSize reservationBufferSize, CacheType cacheType, CacheSize cacheSize) { DataSet = dataSet; Cardinality = cardinality; IndexType = indexType; ReservationBufferSize = reservationBufferSize; CacheType = cacheType; CacheSize = cacheSize; }
public void testExistenceCardinalityAndOccurrences() { // second attribute of root object CAttribute attr = (CAttribute) definition.getAttributes().get(1); Cardinality card = new Cardinality(true, false, interval(0, 8)); assertCAttribute(attr, "members", CAttribute.Existence.OPTIONAL, card, 2); // 1st PERSON CComplexObject obj = (CComplexObject) attr.getChildren().get(0); assertCComplexObject(obj, "PERSON", null, interval(1, 1), 1); // 2nd PERSON obj = (CComplexObject) attr.getChildren().get(1); assertCComplexObject(obj, "PERSON", null, new Interval(new java.lang.Integer(0), null, java.lang.Boolean.TRUE, java.lang.Boolean.FALSE), 1); }
/// <summary> /// Returns the string value of the cardinality value. /// </summary> public static string ConvertToString(Cardinality value) { switch (value) { case Cardinality.OneToOne: return CardinalityConstants.Captions.OneToOne; case Cardinality.ZeroToOne: return CardinalityConstants.Captions.ZeroToOne; case Cardinality.OneToMany: return CardinalityConstants.Captions.OneToMany; case Cardinality.ZeroToMany: return CardinalityConstants.Captions.ZeroToMany; } return CardinalityConstants.Captions.OneToOne; }
private void AppendValues(StringBuilder buffer, GeneralTimingSpecification value, int indentLevel, FormatContext context) { Interval <PlatformDate> duration = value.Duration; IVL <TS, Interval <PlatformDate> > ivlDuration = new IVLImpl <TS, Interval <PlatformDate> >(duration); IvlTsPropertyFormatter formatter = new GtsBoundedPivlFormatter.CustomIvlTsPropertyFormatter(RequiresOperatorOnFirstRepetition (context), RequiresSpecializationType(context)); PeriodicIntervalTime frequency = value.Frequency; buffer.Append(formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("IVL<TS.FULLDATE>" , RequiresSpecializationType(context), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1") , "comp", context), ivlDuration, indentLevel + 1)); // constraints not passed down buffer.Append(CreatePivlTsElement(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("PIVL<TS.DATETIME>" , RequiresSpecializationType(context), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1") , "comp", context), frequency, indentLevel + 1)); }
public AssertionLineBuilder WithCardinality(Cardinality aCardinality) { _cardinality = aCardinality; return(this); }
/// <summary>Get a flag indicating whether or not the relationship is mandatory.</summary> /// <remarks>Get a flag indicating whether or not the relationship is mandatory.</remarks> /// <returns>true if the relationship is mandatory; false otherwise.</returns> public static bool IsMandatory(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality) { return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY.Equals(conformanceLevel)); }
public Association.Association AddAssociation(string associationName, string navigationProperty1Name, EntityType navigationProperty1EnityType, Cardinality navigationProperty1Cardinality, string navigationProperty2Name, EntityType navigationProperty2EnityType, Cardinality navigationProperty2Cardinality) { var association = new Association.Association { Container = this, Name = associationName }; var navigationProperty1 = new NavigationProperty(association) { Name = navigationProperty1Name, Cardinality = navigationProperty1Cardinality }; navigationProperty1EnityType.NavigationProperties.Add(navigationProperty1); association.PropertyEnd1 = navigationProperty1; var navigationProperty2 = new NavigationProperty(association) { Name = navigationProperty2Name, Cardinality = navigationProperty2Cardinality }; navigationProperty2EnityType.NavigationProperties.Add(navigationProperty2); association.PropertyEnd2 = navigationProperty2; return association; }
/// <summary> /// Creates a specification for a new attribute which can be used in a new /// <see cref="MediaItemAspectMetadata"/> instance. /// </summary> /// <param name="attributeName">Name of the string attribute to be created. /// TODO: Describe constraints on the name value. See also other CreateXXXAttributeSpecification methods.</param> /// <param name="attributeType">Type of the attribute to be stored in the attribute to be created. /// For a list of supported attribute types, see <see cref="SUPPORTED_BASIC_TYPES"/>.</param> /// <param name="cardinality">Cardinality of the new attribute.</param> /// <param name="indexed">Set to <c>true</c> if the new attribute should be indexed in the media library. /// This should only be done if the attribute will often occur in filter criteria.</param> public static AttributeSpecification CreateAttributeSpecification(string attributeName, Type attributeType, Cardinality cardinality, bool indexed) { if (!SUPPORTED_BASIC_TYPES.Contains(attributeType)) throw new ArgumentException(string.Format("Attribute type {0} is not supported for media item aspect attributes", attributeType.Name)); return new AttributeSpecification(attributeName, attributeType, cardinality, indexed); }
public InvocationExpectation(Cardinality cardinality) { this.cardinality = cardinality; }
public RoleDefinition() { this.cardinality = Cardinality.Item; }
private Cardinality CalculateContextCardinality(Cardinality context, Type type) { String enumerableName = typeof(IEnumerable<>).Name; if (enumerableName == type.Name || (type.GetInterface(enumerableName) != null)) return Cardinality.ZeroOrMore; return Cardinality.Single; }
/// <summary> /// Gets possible association tables between this entity and the supplied entity. /// </summary> /// <param name="entity1"></param> /// <param name="secondEntity"></param> /// <param name="CardinalityPrimary"></param> /// <param name="CardinalityForeign"></param> /// <returns></returns> public static ITable GetAssociationTable(this Entity entity1, Entity secondEntity, out Cardinality CardinalityPrimary, out Cardinality CardinalityForeign, out IKey mainKey, out IKey associationKey) { CardinalityPrimary = null; CardinalityForeign = null; mainKey = null; associationKey = null; ITable associationTable = null; foreach (ITable table in entity1.GetMappingSet().Database.AssociationTables()) { //ITable primaryTable = table.Relationships.FirstOrDefault(r => entity1.MappedTables().Contains(r.PrimaryTable)); bool primaryFound = false; bool foreignFound = false; #region Primary foreach (Relationship relationship in table.Relationships) { if (entity1.MappedTables().Contains(relationship.PrimaryTable)) { associationTable = table; CardinalityPrimary = relationship.ForeignKey.IsUnique ? Cardinality.One : Cardinality.Many; // relationship.PrimaryCardinality; //CardinalityForeign = relationship.ForeignCardinality; mainKey = relationship.PrimaryKey; //associationKey = relationship.ForeignKey; primaryFound = true; break; } else if (entity1.MappedTables().Contains(relationship.ForeignTable)) { associationTable = table; // relationship.ForeignTable; CardinalityPrimary = relationship.PrimaryKey.IsUnique ? Cardinality.One : Cardinality.Many; // relationship.ForeignCardinality; //CardinalityForeign = relationship.PrimaryCardinality; mainKey = relationship.ForeignKey; //associationKey = relationship.PrimaryKey; primaryFound = true; break; } } #endregion #region Foreign foreach (Relationship relationship in table.Relationships) { if (secondEntity.MappedTables().Contains(relationship.ForeignTable)) { associationTable = table; //CardinalityPrimary = relationship.PrimaryCardinality; CardinalityForeign = relationship.PrimaryKey.IsUnique ? Cardinality.One : Cardinality.Many; // relationship.ForeignCardinality; //mainKey = relationship.PrimaryKey; associationKey = relationship.ForeignKey; foreignFound = true; break; } else if (secondEntity.MappedTables().Contains(relationship.PrimaryTable)) { //associationTable = table;// relationship.ForeignTable; //CardinalityPrimary = relationship.ForeignCardinality; CardinalityForeign = relationship.ForeignKey.IsUnique ? Cardinality.One : Cardinality.Many; // relationship.PrimaryCardinality; //mainKey = relationship.ForeignKey; associationKey = relationship.PrimaryKey; foreignFound = true; break; } } #endregion if (primaryFound && foreignFound) { break; } else { associationTable = null; CardinalityPrimary = null; CardinalityForeign = null; mainKey = null; associationKey = null; } // if (entity1.MappedTables().Contains(relationship.PrimaryTable))// && // //secondEntity.MappedTables().Contains(relationship.ForeignTable)) // { // associationTable = table;// relationship.PrimaryTable; // CardinalityPrimary = relationship.PrimaryCardinality; // CardinalityForeign = relationship.ForeignCardinality; // mainKey = relationship.PrimaryKey; // associationKey = relationship.ForeignKey; // if (oneFound) // break; // else // oneFound = true; // } // else if (entity1.MappedTables().Contains(relationship.ForeignTable) && //secondEntity.MappedTables().Contains(relationship.PrimaryTable)) // { // associationTable = table;// relationship.ForeignTable; // CardinalityPrimary = relationship.ForeignCardinality; // CardinalityForeign = relationship.PrimaryCardinality; // mainKey = relationship.ForeignKey; // associationKey = relationship.PrimaryKey; // if (oneFound) // break; // else // oneFound = true; // } //} } if (associationTable != null) { return(associationTable); } ITable unpureAssociationTable = null; if (associationTable == null) { foreach (ITable table in entity1.MappedTables()) { foreach (Relationship relationship in table.Relationships) { ITable possibleAssociationTable = null; if (entity1.MappedTables().Contains(relationship.PrimaryTable) && Cardinality.IsOneToMany(relationship.ForeignCardinality, relationship.PrimaryCardinality)) { possibleAssociationTable = relationship.ForeignTable; CardinalityPrimary = relationship.PrimaryCardinality; mainKey = relationship.ForeignKey; } else if (entity1.MappedTables().Contains(relationship.ForeignTable) && Cardinality.IsOneToMany(relationship.PrimaryCardinality, relationship.ForeignCardinality)) { possibleAssociationTable = relationship.PrimaryTable; CardinalityPrimary = relationship.ForeignCardinality; mainKey = relationship.PrimaryKey; } if (possibleAssociationTable != null) { foreach (ITable otherTable in secondEntity.MappedTables()) { foreach (Relationship otherRelationship in otherTable.Relationships.Where(r => r.PrimaryTable == possibleAssociationTable || r.ForeignTable == possibleAssociationTable)) { if (otherRelationship.PrimaryTable == otherTable && Cardinality.IsOneToMany(otherRelationship.ForeignCardinality, otherRelationship.PrimaryCardinality) && possibleAssociationTable.Relationships.Where(r => r.PrimaryTable == otherRelationship.ForeignTable || r.ForeignTable == otherRelationship.ForeignTable).Count() > 0) { unpureAssociationTable = otherRelationship.ForeignTable; CardinalityForeign = otherRelationship.PrimaryCardinality; associationKey = otherRelationship.ForeignKey; return(unpureAssociationTable); } else if (otherRelationship.ForeignTable == otherTable && Cardinality.IsOneToMany(otherRelationship.PrimaryCardinality, otherRelationship.ForeignCardinality) && possibleAssociationTable.Relationships.Where(r => r.PrimaryTable == otherRelationship.PrimaryTable || r.ForeignTable == otherRelationship.PrimaryTable).Count() > 0) { unpureAssociationTable = otherRelationship.PrimaryTable; CardinalityForeign = otherRelationship.ForeignCardinality; associationKey = otherRelationship.PrimaryKey; return(unpureAssociationTable); } } } } } } } return(null); }
public virtual void TestIvlTsWithConstraintsInValid() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate dateLow = DateUtil.GetDate(2012, 4, 3); DateWithPattern dateWithPatternLow = new DateWithPattern(dateLow, "yyyyMMdd"); PlatformDate dateHigh = DateUtil.GetDate(2012, 6, 8); DateWithPattern dateWithPatternHigh = new DateWithPattern(dateHigh, "yyyyMMdd"); Interval <PlatformDate> ivlTs = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh ); DateInterval dateInterval = new DateInterval(ivlTs); BareANY dataType = new IVLTSCDAR1Impl(dateInterval); ConstrainedDatatype constraints = new ConstrainedDatatype("ivl", "IVL<TS>"); constraints.Relationships.Add(new Relationship("low", "TS", Cardinality.Create("0"))); constraints.Relationships.Add(new Relationship("high", "TS", Cardinality.Create("0"))); FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, string.Empty , "ivl", "IVLTSCDAR1", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), false, SpecificationVersion .R02_04_03, null, null, null, constraints, true); string xml = this.formatter.Format(formatContext, dataType); Assert.IsFalse(result.IsValid()); Assert.AreEqual(2, result.GetHl7Errors().Count); string expected = "<ivl><low value=\"20120503\"/><high value=\"20120708\"/></ivl>"; AssertXml("ivl output", expected, xml, true); }
public ExpectationBuilder(Cardinality cardinality) { expectation = new InvocationExpectation(cardinality); }
public TypeReferenceSyntax(QualifiedIdentifier name, Cardinality cardinality) { Name = Guard.NotNull(name, "name"); Cardinality = Guard.NotNull(cardinality, "cardinality"); }
public static Signature BinderSignature(String name, Type type, Cardinality cardinality) { return new BinderSignature() { Kind = SignatureKind.Binder, Type = type, Cardinality = cardinality , Name = name}; }
public static Signature ReferenceSignature(Type type, Cardinality cardinality) { return new Signature() { Kind = SignatureKind.Reference, Type = type, Cardinality = cardinality }; }
/// <summary> /// Return a string representation of the XmlQueryType using the specified format. The following formats are /// supported: /// /// "G" (General): This is the default mode, and is used if no other format is recognized. This format is /// easier to read than the canonical format, since it excludes redundant information. /// (e.g. element instead of element(*, xs:anyType)) /// /// "X" (XQuery): Return the canonical XQuery representation, which excludes Qil specific information and /// includes extra, redundant information, such as fully specified types. /// (e.g. element(*, xs:anyType) instead of element) /// /// "S" (Serialized): This format is used to serialize parts of the type which can be serialized easily, in /// a format that is easy to parse. Only the cardinality, type code, and strictness flag /// are serialized. User-defined type information and element/attribute content types /// are lost. /// (e.g. One;Attribute|String|Int;true) /// /// </summary> public string ToString(string format) { string[] sa; StringBuilder sb; bool isXQ; if (format == "S") { sb = new StringBuilder(); sb.Append(Cardinality.ToString(format)); sb.Append(';'); for (int i = 0; i < Count; i++) { if (i != 0) { sb.Append("|"); } sb.Append(this[i].TypeCode.ToString()); } sb.Append(';'); sb.Append(IsStrict); return(sb.ToString()); } isXQ = (format == "X"); if (Cardinality == XmlQueryCardinality.None) { return("none"); } else if (Cardinality == XmlQueryCardinality.Zero) { return("empty"); } sb = new StringBuilder(); switch (Count) { case 0: // This assert depends on the way we are going to represent None sb.Append("none"); break; case 1: sb.Append(this[0].ItemTypeToString(isXQ)); break; default: sa = new string[Count]; for (int i = 0; i < Count; i++) { sa[i] = this[i].ItemTypeToString(isXQ); } Array.Sort(sa); sb = new StringBuilder(); sb.Append('('); sb.Append(sa[0]); for (int i = 1; i < sa.Length; i++) { sb.Append(" | "); sb.Append(sa[i]); } sb.Append(')'); break; } sb.Append(Cardinality.ToString()); if (!isXQ && IsDod) { sb.Append('#'); } return(sb.ToString()); }
public virtual void TestFormatValueNonNull() { string result = new ListPropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (new ModelToXmlResult(), null, "name", "LIST<EN>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, Cardinality. Create("0-4"), false, SpecificationVersion.R02_04_02, null, null, null, false), (BareANY)LISTImpl <ANY <object>, object> .Create <EN <EntityName>, EntityName>(typeof(ENImpl <EntityName>), CreateEntityNameList())); Assert.AreEqual("<name xsi:type=\"PN\"><family>Flinstone</family><given>Fred</given></name>" + SystemUtils.LINE_SEPARATOR + "<name xsi:type=\"PN\"><family>Flinstone</family><given>Wilma</given></name>" + SystemUtils.LINE_SEPARATOR, result, "non null" ); }
/// <summary> /// Creates a specification for a new string attribute which can be used in a new /// <see cref="MediaItemAspectMetadata"/> instance. /// </summary> /// <param name="attributeName">Name of the string attribute to be created. /// TODO: Describe constraints on the name value. See also other CreateXXXAttributeSpecification methods.</param> /// <param name="maxNumChars">Maximum number of characters to be stored in the attribute to /// be created.</param> /// <param name="cardinality">Cardinality of the new attribute.</param> /// <param name="indexed">Set to <c>true</c> if the new attribute should be indexed in the media library. /// This should only be done if the attribute will often occur in filter criteria.</param> public static AttributeSpecification CreateStringAttributeSpecification(string attributeName, uint maxNumChars, Cardinality cardinality, bool indexed) { AttributeSpecification result = new AttributeSpecification(attributeName, typeof(string), cardinality, indexed) { MaxNumChars = maxNumChars }; return(result); }
/// <summary> /// Creates a specification for a new string attribute which can be used in a new /// <see cref="MediaItemAspectMetadata"/> instance. /// </summary> /// <param name="attributeName">Name of the string attribute to be created. /// TODO: Describe constraints on the name value. See also other CreateXXXAttributeSpecification methods.</param> /// <param name="maxNumChars">Maximum number of characters to be stored in the attribute to /// be created.</param> /// <param name="cardinality">Cardinality of the new attribute.</param> /// <param name="indexed">Set to <c>true</c> if the new attribute should be indexed in the media library. /// This should only be done if the attribute will often occur in filter criteria.</param> public static MultipleAttributeSpecification CreateMultipleStringAttributeSpecification(string attributeName, uint maxNumChars, Cardinality cardinality, bool indexed, params int[] compositeIndexIds) { MultipleAttributeSpecification result = new MultipleAttributeSpecification(attributeName, typeof(string), cardinality, indexed, compositeIndexIds) { MaxNumChars = maxNumChars }; return(result); }
private static Element CreateElement(IElementContainer parent, string elementName, Cardinality cardinality) { var child = (Element)parent.CreateElement(); var elementInstanceCount = parent.Elements.Where(e => e.DefinitionName == elementName).Count() + 1; child.DefinitionName = elementName; child.InstanceName = elementName + elementInstanceCount.ToString(); child.Info = Mock.Of<IElementInfo>(ei => ei.Name == elementName && ei.CodeIdentifier == elementName && ei.Cardinality == cardinality); var property = CreateProperty(child, elementName + "Property1", elementName + "Value1"); return child; }
internal AttributeSpecification(string name, Type type, Cardinality cardinality, bool indexed) { _attributeName = name; _attributeType = type; _cardinality = cardinality; _indexed = indexed; }
private static Element CreateElement(IElementContainer parent, string elementName, Cardinality cardinality = Cardinality.OneToOne, Action<Element> initializer = null) { var element = CreateElement(parent, elementName, cardinality); if (initializer != null) { initializer(element); } return element; }
// Query nodes public virtual TypeNode GetResultType(Expression source, TypeNode elementType, Cardinality card){ if (source == null) return null; TypeNode stype = source.Type; if (stype == null) return null; if (elementType == null){ if (source is Literal && stype == SystemTypes.Type){ elementType = (TypeNode)((Literal)source).Value; } else{ elementType = (stype is TupleType) ? stype : this.typeSystem.GetStreamElementType(source, this.TypeViewer); } } Cardinality resultCard = this.typeSystem.GetCardinalityOr(this.typeSystem.GetCardinality(source, this.TypeViewer), card); Cardinality elementCard = this.typeSystem.GetCardinality(elementType, this.TypeViewer); switch( resultCard ){ case Cardinality.None: return elementType; case Cardinality.ZeroOrOne: if (this.typeSystem.GetCardinality(elementType, this.TypeViewer) == Cardinality.ZeroOrOne){ return elementType; } else if(elementType.Template == SystemTypes.GenericNonNull){ return this.typeSystem.GetStreamElementType(elementType, this.TypeViewer); } else{ return SystemTypes.GenericBoxed.GetTemplateInstance(this.currentType, elementType); } default: case Cardinality.ZeroOrMore: return SystemTypes.GenericIEnumerable.GetTemplateInstance(this.currentType, elementType); case Cardinality.One: if (this.typeSystem.GetCardinality(elementType, this.TypeViewer) == Cardinality.One){ return elementType; } else if (elementType.Template == SystemTypes.GenericBoxed){ return this.typeSystem.GetStreamElementType(elementType, this.TypeViewer); } else{ return SystemTypes.GenericNonNull.GetTemplateInstance(this.currentType, elementType); } case Cardinality.OneOrMore: return SystemTypes.GenericNonEmptyIEnumerable.GetTemplateInstance(this.currentType, elementType); } }
private void SerialiseCardinalityInternal(XmlWriter writer, string elementName, Cardinality cardinality) { writer.WriteStartElement(elementName); if (cardinality == null) { cardinality = Cardinality.One; } writer.WriteAttributeString("min", cardinality.Start.ToString()); writer.WriteAttributeString("max", cardinality.End.ToString()); writer.WriteEndElement(); }
public static Signature ValueSignature(Type type, Cardinality cardinality) { return new Signature() { Kind = SignatureKind.Value, Type = type, Cardinality = cardinality }; }
public TypeReference(TypeLookup type, Cardinality cardinality) { _TypeLookup = Guard.NotNull(type, "type"); Cardinality = Guard.NotNull(cardinality, "cardinality"); }
/// <summary>Get a flag indicating whether or not the relationship is populated.</summary> /// <remarks>Get a flag indicating whether or not the relationship is populated.</remarks> /// <returns>true if the relationship is populated; false otherwise.</returns> public static bool IsPopulated(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality) { // - this *almost* matches what MB was doing prior to a Remixer change to BaseMifProcessorImpl // - IGNORED and NOT_ALLOWED with a min cardinality > 0 (a very strange state!) will behave differently than before the Remixer change // - populated should eventually be removed as a conformance altogether return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED.Equals(conformanceLevel) || (Ca.Infoway.Messagebuilder.Xml.ConformanceLevel .REQUIRED.Equals(conformanceLevel) && cardinality.Mandatory)); }
public virtual void TestFormatValueNonNull() { string result = new SetPropertyFormatter(this.formatterRegistry).Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (new ModelToXmlResult(), null, "blah", "SET<TEL.PHONEMAIL>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality .Create("1-4"), false, SpecificationVersion.R02_04_03, null, null, null, false), SETImpl <ANY <object>, object> .Create <TEL , TelecommunicationAddress>(typeof(TELImpl), MakeTelecommunicationAddressSet("Fred"))); AssertXml("non null", "<blah specializationType=\"TEL.PHONE\" value=\"mailto:Fred\" xsi:type=\"TEL\"/>", result); }
private bool IsSingleCardinality(Cardinality cardinality) { return(cardinality == null ? true : cardinality.Single); }
public static Ca.Infoway.Messagebuilder.Error.Hl7Error CreateWrongNumberOfAssociationsError(string xmlName, XmlElement @base , int size, Cardinality cardinality) { return(new Ca.Infoway.Messagebuilder.Error.Hl7Error(Hl7ErrorCode.NUMBER_OF_ASSOCIATIONS_INCORRECT_FOR_CARDINALITY, System.String.Format ("Association \"{0}\" has a cardinality of \"{1}\", but {2} occurrences were found ({3}). For cases where the association only supports a single value, only the first occurence will have been retained." , xmlName, cardinality, size, XmlDescriber.DescribeSingleElement(@base)), @base)); }
protected void Validate(Cardinality cardinality) { Invariant(cardinality.Interval != null, string.Format( CommonStrings.XMustNotBeNull, "Cardinality.Interval")); Invariant(!cardinality.Interval.LowerUnbounded, AmValidationStrings.CardinalityLowerUnbounded); }
protected void CompileStatementParts(MIA_Management miaManagement, IFilter filter, Namespace ns, BindVarNamespace bvNamespace, ICollection <MediaItemAspectMetadata> requiredMIATypes, string outerMIIDJoinVariable, ICollection <TableJoin> tableJoins, IList <object> resultParts, IList <BindVar> resultBindVars) { if (filter == null) { return; } MediaItemIdFilter mediaItemIdFilter = filter as MediaItemIdFilter; if (mediaItemIdFilter != null) { ICollection <Guid> mediaItemIds = mediaItemIdFilter.MediaItemIds; if (mediaItemIds.Count == 0) { resultParts.Add("1 = 2"); } else { if (mediaItemIds.Count == 1) { resultParts.Add(outerMIIDJoinVariable); BindVar bindVar = new BindVar(bvNamespace.CreateNewBindVarName("V"), mediaItemIds.First(), typeof(Guid)); resultParts.Add(" = @" + bindVar.Name); resultBindVars.Add(bindVar); } else { bool first = true; ICollection <string> clusterExpressions = new List <string>(); foreach (IList <Guid> mediaItemIdsCluster in CollectionUtils.Cluster(mediaItemIds, MAX_IN_VALUES_SIZE)) { IList <string> bindVarRefs = new List <string>(MAX_IN_VALUES_SIZE); foreach (Guid mediaItemId in mediaItemIdsCluster) { BindVar bindVar = new BindVar(bvNamespace.CreateNewBindVarName("V"), mediaItemId, typeof(Guid)); bindVarRefs.Add("@" + bindVar.Name); resultBindVars.Add(bindVar); } if (!first) { resultParts.Add(" OR "); } first = false; resultParts.Add(outerMIIDJoinVariable); resultParts.Add(" IN (" + StringUtils.Join(", ", bindVarRefs) + ")"); } resultParts.Add(StringUtils.Join(" OR ", clusterExpressions)); } } return; } BooleanCombinationFilter boolFilter = filter as BooleanCombinationFilter; if (boolFilter != null) { int numOperands = boolFilter.Operands.Count; IEnumerator enumOperands = boolFilter.Operands.GetEnumerator(); if (!enumOperands.MoveNext()) { return; } if (numOperands > 1) { resultParts.Add("("); } CompileStatementParts(miaManagement, (IFilter)enumOperands.Current, ns, bvNamespace, requiredMIATypes, outerMIIDJoinVariable, tableJoins, resultParts, resultBindVars); while (enumOperands.MoveNext()) { switch (boolFilter.Operator) { case BooleanOperator.And: resultParts.Add(" AND "); break; case BooleanOperator.Or: resultParts.Add(" OR "); break; default: throw new NotImplementedException(string.Format( "Boolean filter operator '{0}' isn't supported by the media library", boolFilter.Operator)); } CompileStatementParts(miaManagement, (IFilter)enumOperands.Current, ns, bvNamespace, requiredMIATypes, outerMIIDJoinVariable, tableJoins, resultParts, resultBindVars); } if (numOperands > 1) { resultParts.Add(")"); } return; } NotFilter notFilter = filter as NotFilter; if (notFilter != null) { resultParts.Add("NOT ("); CompileStatementParts(miaManagement, notFilter.InnerFilter, ns, bvNamespace, requiredMIATypes, outerMIIDJoinVariable, tableJoins, resultParts, resultBindVars); resultParts.Add(")"); return; } FalseFilter falseFilter = filter as FalseFilter; if (falseFilter != null) { resultParts.Add("1 = 2"); return; } // Must be done before checking IAttributeFilter - EmptyFilter is also an IAttributeFilter but must be // compiled in a different way EmptyFilter emptyFilter = filter as EmptyFilter; if (emptyFilter != null) { MediaItemAspectMetadata.AttributeSpecification attributeType = emptyFilter.AttributeType; requiredMIATypes.Add(attributeType.ParentMIAM); Cardinality cardinality = attributeType.Cardinality; if (cardinality == Cardinality.Inline || cardinality == Cardinality.ManyToOne) { resultParts.Add(new QueryAttribute(attributeType)); resultParts.Add(" IS NULL"); // MTO attributes are joined with left outer joins and thus can also be checked for NULL } else if (cardinality == Cardinality.OneToMany) { resultParts.Add("NOT EXISTS("); resultParts.Add("SELECT V."); resultParts.Add(MIA_Management.MIA_MEDIA_ITEM_ID_COL_NAME); resultParts.Add(" FROM "); resultParts.Add(miaManagement.GetMIACollectionAttributeTableName(attributeType)); resultParts.Add(" V WHERE V."); resultParts.Add(MIA_Management.MIA_MEDIA_ITEM_ID_COL_NAME); resultParts.Add("="); resultParts.Add(outerMIIDJoinVariable); resultParts.Add(")"); } else if (cardinality == Cardinality.ManyToMany) { resultParts.Add("NOT EXISTS("); resultParts.Add("SELECT NM."); resultParts.Add(MIA_Management.MIA_MEDIA_ITEM_ID_COL_NAME); resultParts.Add(" FROM "); resultParts.Add(miaManagement.GetMIACollectionAttributeNMTableName(attributeType)); resultParts.Add(" NM INNER JOIN "); resultParts.Add(miaManagement.GetMIACollectionAttributeTableName(attributeType)); resultParts.Add(" V ON NM."); resultParts.Add(MIA_Management.FOREIGN_COLL_ATTR_ID_COL_NAME); resultParts.Add(" = V."); resultParts.Add(MIA_Management.FOREIGN_COLL_ATTR_ID_COL_NAME); resultParts.Add(" WHERE NM."); resultParts.Add(MIA_Management.MIA_MEDIA_ITEM_ID_COL_NAME); resultParts.Add("="); resultParts.Add(outerMIIDJoinVariable); resultParts.Add(")"); } return; } IAttributeFilter attributeFilter = filter as IAttributeFilter; if (attributeFilter != null) { // For attribute filters, we have to create different kinds of expressions, depending on the // cardinality of the attribute to be filtered. // For Inline and MTO attributes, we simply create // // QA [Operator] [Comparison-Value] // // for OTM attributes, we create // // INNER JOIN [OTM-Value-Table] V ON V.MEDIA_ITEM_ID=[Outer-Join-Variable-Placeholder] // WHERE [...] and V.VALUE [Operator] [Comparison-Value]) // // for MTM attributes, we create // // INNER JOIN [MTM-NM-Table] NM ON NM.MEDIA_ITEM_ID=[Outer-Join-Variable-Placeholder] // INNER JOIN [MTM-Value-Table] V ON NM.ID = V.ID // WHERE [...] AND V.VALUE [Operator] [Comparison-Value]) MediaItemAspectMetadata.AttributeSpecification attributeType = attributeFilter.AttributeType; requiredMIATypes.Add(attributeType.ParentMIAM); Cardinality cardinality = attributeType.Cardinality; if (cardinality == Cardinality.Inline || cardinality == Cardinality.ManyToOne) { BuildAttributeFilterExpression(attributeFilter, new QueryAttribute(attributeType), bvNamespace, resultParts, resultBindVars); } else if (cardinality == Cardinality.OneToMany) { string joinTable = miaManagement.GetMIACollectionAttributeTableName(attributeType); string attrName; if (!_innerJoinedTables.TryGetValue(joinTable, out attrName)) { TableQueryData tqd = new TableQueryData(joinTable); tableJoins.Add(new TableJoin("LEFT OUTER JOIN", tqd, new RequestedAttribute(tqd, MIA_Management.MIA_MEDIA_ITEM_ID_COL_NAME), outerMIIDJoinVariable)); attrName = new RequestedAttribute(tqd, MIA_Management.COLL_ATTR_VALUE_COL_NAME).GetQualifiedName(ns); _innerJoinedTables.Add(joinTable, attrName); } BuildAttributeFilterExpression(attributeFilter, attrName, bvNamespace, resultParts, resultBindVars); } else if (cardinality == Cardinality.ManyToMany) { string miaCollectionAttributeNMTableName = miaManagement.GetMIACollectionAttributeNMTableName(attributeType); string attrName; if (!_innerJoinedTables.TryGetValue(miaCollectionAttributeNMTableName, out attrName)) { TableQueryData tqdMiaCollectionAttributeNMTable = new TableQueryData(miaCollectionAttributeNMTableName); tableJoins.Add(new TableJoin("LEFT OUTER JOIN", tqdMiaCollectionAttributeNMTable, new RequestedAttribute(tqdMiaCollectionAttributeNMTable, MIA_Management.MIA_MEDIA_ITEM_ID_COL_NAME), outerMIIDJoinVariable)); TableQueryData tqdMiaCollectionAttributeTable = new TableQueryData(miaManagement.GetMIACollectionAttributeTableName(attributeType)); tableJoins.Add(new TableJoin("LEFT OUTER JOIN", tqdMiaCollectionAttributeTable, new RequestedAttribute(tqdMiaCollectionAttributeNMTable, MIA_Management.FOREIGN_COLL_ATTR_ID_COL_NAME), new RequestedAttribute(tqdMiaCollectionAttributeTable, MIA_Management.FOREIGN_COLL_ATTR_ID_COL_NAME))); attrName = tqdMiaCollectionAttributeTable.GetAlias(ns) + "." + MIA_Management.COLL_ATTR_VALUE_COL_NAME; _innerJoinedTables.Add(miaCollectionAttributeNMTableName, attrName); } BuildAttributeFilterExpression(attributeFilter, attrName, bvNamespace, resultParts, resultBindVars); } return; } throw new InvalidDataException("Filter type '{0}' isn't supported by the media library", filter.GetType().Name); }
public IntOptions Fast(Cardinality cardinality) { _impl.SetFast(cardinality); return(this); }
protected override string FormatDenominator(FormatContext context, PhysicalQuantity denominator, int indentLevel) { string denominatorType = Hl7DataTypeName.Create(context.Type).GetInnerTypes()[1].ToString(); FormatContext newContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(denominatorType, context .IsSpecializationType(), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), "denominator" , context); return(this.pqFormatter.Format(newContext, new PQImpl(denominator), indentLevel)); }
public virtual void TestParse() { XmlNode node = CreateNode("<top>" + "<something>" + "<numerator unit=\"mg\" value=\"1000\" />" + "<denominator unit=\"d\" value=\"1\" />" + "</something>" + "<something>" + "<numerator unit=\"mg\" value=\"1001\" />" + "<denominator unit=\"d\" value=\"2\" />" + "</something>" + "</top>"); BareANY result = new SetElementParser(ParserRegistry.GetInstance()).Parse(ParseContextImpl.Create("SET<RTO<PQ.DRUG,PQ.TIME>>" , null, SpecificationVersion.V01R04_2_SK, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality .Create("1-5"), null, false), AsList(node.ChildNodes), null); ICollection <Ratio <PhysicalQuantity, PhysicalQuantity> > set = ((SET <RTO <PhysicalQuantity, PhysicalQuantity>, Ratio <PhysicalQuantity , PhysicalQuantity> >)result).RawSet(); Assert.IsNotNull(set, "null"); Assert.AreEqual(2, set.Count, "size"); bool foundFirst = false; bool foundSecond = false; foreach (Ratio <PhysicalQuantity, PhysicalQuantity> ratio in set) { if (ratio.Numerator.Quantity.Value == 1000 && ratio.Denominator.Quantity.Value == 1) { foundFirst = true; } else { if (ratio.Numerator.Quantity.Value == 1001 && ratio.Denominator.Quantity.Value == 2) { foundSecond = true; } } } Assert.IsTrue(foundFirst); Assert.IsTrue(foundSecond); }
/// <summary> /// Returns whether the cardinality is either <see cref="Cardinality.ZeroToOne"/> or <see cref="Cardinality.OneToOne"/> /// </summary> public static bool IsAnyToOne(this Cardinality cardinality) { return(cardinality == Cardinality.OneToOne || cardinality == Cardinality.ZeroToOne); }
public MultipleAttributeSpecification(string name, Type type, Cardinality cardinality, bool indexed, params int[] compositeIndexIds) : base(name, type, cardinality, indexed, compositeIndexIds) { }
/// <summary> /// Returns whether the cardinality is either <see cref="Cardinality.ZeroToMany"/> or <see cref="Cardinality.OneToMany"/> /// </summary> public static bool IsAnyToMany(this Cardinality cardinality) { return(cardinality == Cardinality.OneToMany || cardinality == Cardinality.ZeroToMany); }
/// <summary> /// Creates a specification for a new attribute which can be used in a new /// <see cref="MediaItemAspectMetadata"/> instance. /// </summary> /// <param name="attributeName">Name of the string attribute to be created. /// TODO: Describe constraints on the name value. See also other CreateXXXAttributeSpecification methods.</param> /// <param name="attributeType">Type of the attribute to be stored in the attribute to be created. /// For a list of supported attribute types, see <see cref="SUPPORTED_BASIC_TYPES"/>.</param> /// <param name="cardinality">Cardinality of the new attribute.</param> /// <param name="indexed">Set to <c>true</c> if the new attribute should be indexed in the media library. /// This should only be done if the attribute will often occur in filter criteria.</param> public static SingleAttributeSpecification CreateSingleAttributeSpecification(string attributeName, Type attributeType, Cardinality cardinality, bool indexed, params int[] compositeIndexIds) { if (!SUPPORTED_BASIC_TYPES.Contains(attributeType)) { throw new ArgumentException(string.Format("Attribute type {0} is not supported for media item aspect attributes", attributeType.Name)); } return(new SingleAttributeSpecification(attributeName, attributeType, cardinality, indexed, compositeIndexIds)); }
public UIAssociation AddAssociation(string associationName, string navigationProperty1Name, UIEntityType navigationProperty1EntityType, Cardinality navigationProperty1Cardinality, string navigationProperty2Name, UIEntityType navigationProperty2EntityType, Cardinality navigationProperty2Cardinality) { var association = CSDL.AddAssociation(associationName, navigationProperty1Name, navigationProperty1EntityType.BusinessInstance, navigationProperty1Cardinality, navigationProperty2Name, navigationProperty2EntityType.BusinessInstance, navigationProperty2Cardinality); return new UIAssociation { NavigationProperty1 = navigationProperty1EntityType.Properties[association.PropertyEnd1] as UIRelatedProperty, NavigationProperty2 = navigationProperty2EntityType.Properties[association.PropertyEnd2] as UIRelatedProperty }; }
public virtual Cardinality GetCardinalityOr(Cardinality source, Cardinality element) { switch( source ) { case Cardinality.None: switch( element ) { case Cardinality.None: return Cardinality.None; case Cardinality.One: return Cardinality.None; case Cardinality.ZeroOrOne: return Cardinality.ZeroOrOne; case Cardinality.OneOrMore: return Cardinality.ZeroOrMore; case Cardinality.ZeroOrMore: return Cardinality.ZeroOrMore; } break; case Cardinality.ZeroOrOne: switch( element ) { case Cardinality.None: return Cardinality.ZeroOrOne; case Cardinality.One: return Cardinality.ZeroOrOne; case Cardinality.ZeroOrOne: return Cardinality.ZeroOrOne; case Cardinality.OneOrMore: return Cardinality.ZeroOrMore; case Cardinality.ZeroOrMore: return Cardinality.ZeroOrMore; } break; case Cardinality.ZeroOrMore: return Cardinality.ZeroOrMore; case Cardinality.One: switch (element) { case Cardinality.None: return Cardinality.None; case Cardinality.One: return Cardinality.One; case Cardinality.ZeroOrOne: return Cardinality.ZeroOrOne; case Cardinality.OneOrMore: return Cardinality.OneOrMore; case Cardinality.ZeroOrMore: return Cardinality.ZeroOrMore; default: return element; } case Cardinality.OneOrMore: switch( element ) { case Cardinality.None: return Cardinality.ZeroOrMore; case Cardinality.One: return Cardinality.OneOrMore; case Cardinality.ZeroOrOne: return Cardinality.ZeroOrMore; case Cardinality.OneOrMore: return Cardinality.OneOrMore; case Cardinality.ZeroOrMore: return Cardinality.ZeroOrMore; } break; } return Cardinality.None; }
/// <summary> /// Serializes the specified cardinality. /// </summary> /// <param name="cardinality">The cardinality.</param> private void Serialize(Cardinality cardinality) { _writer.Write(cardinality.EnumValue); }
/// <summary> /// Creates a specification for a new string attribute which can be used in a new /// <see cref="MediaItemAspectMetadata"/> instance. /// </summary> /// <param name="attributeName">Name of the string attribute to be created. /// TODO: Describe constraints on the name value. See also other CreateXXXAttributeSpecification methods.</param> /// <param name="maxNumChars">Maximum number of characters to be stored in the attribute to /// be created.</param> /// <param name="cardinality">Cardinality of the new attribute.</param> /// <param name="indexed">Set to <c>true</c> if the new attribute should be indexed in the media library. /// This should only be done if the attribute will often occur in filter criteria.</param> public static AttributeSpecification CreateStringAttributeSpecification(string attributeName, uint maxNumChars, Cardinality cardinality, bool indexed) { AttributeSpecification result = new AttributeSpecification(attributeName, typeof(string), cardinality, indexed) {MaxNumChars = maxNumChars}; return result; }
/// <summary>Get a flag indicating whether or not the relationship is required.</summary> /// <remarks>Get a flag indicating whether or not the relationship is required.</remarks> /// <returns>true if the relationship is required; false otherwise.</returns> public static bool IsRequired(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality) { return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.REQUIRED.Equals(conformanceLevel) && !cardinality.Mandatory); }
public RoleDefinition() { this.cardinalityField = Cardinality.Item; }
/// <summary>Get a flag indicating whether or not the relationship is optional.</summary> /// <remarks>Get a flag indicating whether or not the relationship is optional.</remarks> /// <returns>true if the relationship is optional; false otherwise.</returns> public static bool IsOptional(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality) { return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL.Equals(conformanceLevel)); }
/// <summary>Get a flag indicating whether or not the relationship is ignored.</summary> /// <remarks>Get a flag indicating whether or not the relationship is ignored.</remarks> /// <returns>true if the relationship is ignored; false otherwise.</returns> public static bool IsIgnored(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality) { return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.IGNORED.Equals(conformanceLevel)); }
/// <summary>Get a flag indicating whether or not the relationship is not allowed.</summary> /// <remarks>Get a flag indicating whether or not the relationship is not allowed.</remarks> /// <returns>true if the relationship is not allowed; false otherwise.</returns> public static bool IsNotAllowed(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel conformanceLevel, Cardinality cardinality) { return(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.NOT_ALLOWED.Equals(conformanceLevel)); }
public UIAssociation AddAssociation(string associationName, string navigationProperty1Name, UIEntityType navigationProperty1EntityType, Cardinality navigationProperty1Cardinality, string navigationProperty2Name, UIEntityType navigationProperty2EntityType, Cardinality navigationProperty2Cardinality) { var association = CSDL.AddAssociation(associationName, navigationProperty1Name, navigationProperty1EntityType.BusinessInstance, navigationProperty1Cardinality, navigationProperty2Name, navigationProperty2EntityType.BusinessInstance, navigationProperty2Cardinality); return(new UIAssociation { NavigationProperty1 = navigationProperty1EntityType.Properties[association.PropertyEnd1] as UIRelatedProperty, NavigationProperty2 = navigationProperty2EntityType.Properties[association.PropertyEnd2] as UIRelatedProperty }); }
public bool Equals(Cardinality obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; return obj.Start == Start && obj.End == End; }