use of org.whole.lang.xsd.codebase.IMappingStrategy in project whole by wholeplatform.
the class MappingStrategyUtils method getElementNCName.
public static String getElementNCName(IEntity entity) {
EntityDescriptor<?> context;
FeatureDescriptor fd;
IEntity parent = entity.wGetParent();
if (EntityUtils.isNull(parent)) {
context = CommonsEntityDescriptorEnum.RootFragment;
fd = CommonsFeatureDescriptorEnum.rootEntity;
} else {
context = parent.wGetEntityDescriptor();
fd = parent.wGetFeatureDescriptor(entity);
}
IMappingStrategy strategy = getMappingStrategy(context.getLanguageKit().getURI());
return strategy == null ? null : strategy.getElementNCName(context, entity.wGetEntityDescriptor(), fd);
}
use of org.whole.lang.xsd.codebase.IMappingStrategy in project whole by wholeplatform.
the class MappingStrategyUtils method getAttributeNCName.
public static String getAttributeNCName(IEntity entity) {
EntityDescriptor<?> context;
FeatureDescriptor fd;
IEntity parent = entity.wGetParent();
if (EntityUtils.isNull(parent)) {
context = CommonsEntityDescriptorEnum.RootFragment;
fd = CommonsFeatureDescriptorEnum.rootEntity;
} else {
context = parent.wGetEntityDescriptor();
fd = parent.wGetFeatureDescriptor(entity);
}
IMappingStrategy strategy = getMappingStrategy(context.getLanguageKit().getURI());
return strategy == null ? null : strategy.getAttributeNCName(context, entity.wGetEntityDescriptor(), fd);
}
use of org.whole.lang.xsd.codebase.IMappingStrategy in project whole by wholeplatform.
the class XsiModelTemplate method applyAttributes.
protected void applyAttributes(IEntity entity, int fromIndex) {
final int size = entity.wSize();
for (int i = fromIndex; i < size; i++) {
EntityDescriptor<?> context = entity.wGetEntityDescriptor();
FeatureDescriptor fd = entity.wGetFeatureDescriptor(i);
IEntity child = entity.wGet(i);
EntityDescriptor<?> ed = child.wGetEntityDescriptor();
String languageURI = ed.getLanguageKit().getURI();
// FIXME workaround for resolvers and other adapted entities
if (CommonsLanguageKit.URI.equals(ed.getLanguageKit().getURI())) {
ed = child.wGetParent().wGetEntityDescriptor();
languageURI = ed.getLanguageKit().getURI();
}
IMappingStrategy strategy = getXsiMappingStrategy(languageURI);
if (isAttributeMapping(strategy, context, ed, fd)) {
if (!EntityUtils.isResolver(child) || !fd.isOptional()) {
builder.Attribute_();
String attrName = getAttributeNCName(strategy, context, ed, fd);
// TODO add any attribute support
boolean needNamespacePrefix = strategy.isAttributesFormQualified() && !NamespaceUtils.isInternalNamespace(languageURI);
if (needNamespacePrefix) {
String prefix = getNamespacePrefix(child, languageURI);
builder.QualifiedName_();
builder.NameSpace(prefix);
builder.Name(attrName);
builder._QualifiedName();
} else
builder.Name(attrName);
builder.Value(toAttributeValue(child, strategy));
builder._Attribute();
}
}
}
}
use of org.whole.lang.xsd.codebase.IMappingStrategy in project whole by wholeplatform.
the class XsdLanguageKit method getDataTypeParser.
@Override
public IDataTypeParser getDataTypeParser(DataTypeParsers kind) {
if (dataTypeParser == null) {
IMappingStrategy mappingStrategy = MappingStrategyRegistry.instance().getMappingStrategy(getURI());
if (mappingStrategy == null)
return super.getDataTypeParser(kind);
dataTypeParser = new XsiDataTypeParser(mappingStrategy.getDataTypeParsers());
}
return dataTypeParser;
}
use of org.whole.lang.xsd.codebase.IMappingStrategy in project whole by wholeplatform.
the class XsiOutlineEditorKit method canApply.
public boolean canApply(ILanguageKit languageKit) {
String languageURI = languageKit.getURI();
IMappingStrategy mappingStrategy = MappingStrategyRegistry.instance().getMappingStrategy(languageURI);
return mappingStrategy != null && !NamespaceUtils.isXsdNamespace(languageURI);
}
Aggregations