public void matchSubsetLiterals() { if (this.subsetElement != null) { var subsetEnumeration = this.subsetElement as UTF_EA.Enumeration; if (subsetEnumeration != null) { foreach (UTF_EA.EnumerationLiteral literal in subsetEnumeration.ownedLiterals) { EASchemaLiteral matchingLiteral = this.getMatchingSchemaLiteral(literal); if (matchingLiteral != null) { //found a match matchingLiteral.subSetLiteral = literal; } else { //only delete if stereotype not in list of ignored stereotypes if (literal.stereotypes.Count(x => this.owner.settings.ignoredStereotypes.Contains(x.name)) <= 0) { //no match, delete the literal literal.delete(); } } } } } }
public void matchSubsetLiterals() { if (this.subsetElement != null) { var subsetElementWrapper = subsetElement as UTF_EA.ElementWrapper; if (subsetElementWrapper != null) { foreach (UTF_EA.EnumerationLiteral literal in subsetElementWrapper.ownedLiterals) { //tell the user what we are doing EAOutputLogger.log(this.model, this.owner.settings.outputName, "Matching subset literal: '" + literal.name + "' to a schema property" , subsetElementWrapper.id, LogTypeEnum.log); EASchemaLiteral matchingLiteral = this.getMatchingSchemaLiteral(literal); if (matchingLiteral != null) { //found a match matchingLiteral.subSetLiteral = literal; } else { //only delete if stereotype not in list of ignored stereotypes if (literal.stereotypes.Count(x => this.owner.settings.ignoredStereotypes.Contains(x.name)) <= 0) { //no match, delete the literal literal.delete(); } } } } } }
/// <summary> /// gets the SchemaLiteral that corresponds with the given literal value /// </summary> /// <param name="literal">the literal to match</param> /// <returns>the corresponding SchemaLiteral</returns> EASchemaLiteral getMatchingSchemaLiteral(UTF_EA.EnumerationLiteral literal) { EASchemaLiteral result = null; var sourceAttributeTag = literal.getTaggedValue(this.owner.settings.sourceAttributeTagName); if (sourceAttributeTag != null) { string tagReference = sourceAttributeTag.eaStringValue; foreach (EASchemaLiteral schemaLiteral in this.schemaLiterals) { //we have the same attribute if the given attribute has a tagged value //called sourceAttribute that refences the source attribute of the schema Property if (((UTF_EA.EnumerationLiteral)schemaLiteral.sourceLiteral).guid == tagReference) { result = schemaLiteral; break; } } } return(result); }