public static FacetValue getEnterpriseFacetValue(final XSDSimpleTypeDefinition startingType) { FacetValue fv = new FacetValue(); final XSDSimpleTypeDefinition definingEnterpriseType = getDefiningEnterpriseType(startingType); fv.type = startingType; EnterpriseDatatypeInfo edi = ModelerCore.getWorkspaceDatatypeManager().getEnterpriseDatatypeInfo(definingEnterpriseType); fv.value = edi.getRuntimeType(); if (startingType == definingEnterpriseType) { // this "facet" set in the specified type, so it is not default. // check parent for real default: final XSDSimpleTypeDefinition dftDefiner = getDefiningEnterpriseType(definingEnterpriseType.getBaseTypeDefinition()); EnterpriseDatatypeInfo ediDft = ModelerCore.getWorkspaceDatatypeManager().getEnterpriseDatatypeInfo(dftDefiner); fv.defaultValue = ediDft.getRuntimeType(); // set a fake facet to allow inherited checks to work: fv.facet = new XSDConstrainingFacetImpl() { @Override public String getFacetName() { return "This is not a real facet!"; //$NON-NLS-1$ } @Override public XSDConcreteComponent getContainer() { return dftDefiner; } }; // endanon } else { // facet set by a parent, so it is default: fv.defaultValue = fv.value; // set a fake facet to allow inherited checks to work: fv.facet = new XSDConstrainingFacetImpl() { @Override public String getFacetName() { return "This is not a real facet!"; //$NON-NLS-1$ } @Override public XSDConcreteComponent getContainer() { return definingEnterpriseType; } }; // endanon } // endif Boolean rtFixed = edi.getRuntimeTypeFixed(); if (rtFixed != null) { fv.isFixedLocal = rtFixed.booleanValue(); } // endif -- fixed null return fv; }
public static FacetValue getFacetValue(XSDSimpleTypeDefinition type, XSDConstrainingFacet facet) { FacetValue fv = new FacetValue(); fv.description = ModelObjectUtilities.getDescription(facet); fv.type = type; fv.facet = facet; Object mainVal = getMainFacetValue(facet); if (mainVal != null) { fv.value = mainVal; } else { fv.value = getDefaultMainFacetValue(facet.getFacetName()); } // endif if (type == facet.getContainer()) { // this facet set in the specified type, so it is not default: fv.defaultValue = null; // getMainFacetValue(type.getBaseTypeDefinition(), facet.getFacetName()); } else { // facet set by a parent, so it is default: fv.defaultValue = fv.value; } // endif fv.isFixedLocal = isFixed(facet); return fv; }