use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class ActionsUIEntityFactory method createPersistencesGroupAction.
public GroupAction createPersistencesGroupAction(ActionKindEnum.Value kind, Set<String> excludeSet, EntityDescriptor<?> resultEd) {
GroupAction groupAction = createHierarchicalGroupAction(resultEd.getLanguageKit().getName() + ".persistences");
Actions actions = createActions(0);
for (IPersistenceKit persistenceKit : ReflectionFactory.getPersistenceKits()) actions.wAdd(createTemplateAction(kind, create(resultEd, persistenceKit.getId()), persistenceKit.getDescription(), IActionConstants.SELECT_PERSISTENCE_ICON, kind == ActionKindEnum.REPLACE));
groupAction.setActions(actions);
return groupAction;
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class AbstractArtifactsGeneratorVisitor method writeContents.
protected void writeContents(IEntity model) {
IPersistenceProvider pp = (IPersistenceProvider) env().wGetValue("persistenceProvider");
boolean contentsWritten = false;
if (env().wIsSet("persistenceKitId")) {
IPersistenceKit pk = ReflectionFactory.getPersistenceKit(env().wStringValue("persistenceKitId"));
if (pk.canApply(model))
try {
pk.writeModel(model, pp);
contentsWritten = true;
} catch (Exception inner) {
throw new IllegalStateException(inner);
}
}
try {
if (!contentsWritten)
PrettyPrintPersistenceKit.instance().writeModel(model, pp);
} catch (RuntimeException runtime) {
throw runtime;
} catch (Exception outer) {
throw new IllegalStateException(outer);
}
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class ArtifactsLoadFileContentsVisitor method getPersistenceKit.
private IPersistenceKit getPersistenceKit(IEntity entity) {
String persistenceKitId = getPersistenceKitId(entity);
IPersistenceKit persistenceKit = persistenceKitId != null ? ReflectionFactory.getPersistenceKit(persistenceKitId) : persistenceKitStack.peek();
if (persistenceKit == null)
throw new IllegalStateException("default persistence undefined");
return persistenceKit;
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class ArtifactsLoadFileContentsVisitor method visit.
@Override
public void visit(FileArtifact entity) {
if (force || EntityUtils.isResolver(entity.getContent())) {
InputStream is = getArtifactsOperations().getContents(getResource());
IPersistenceKit persistenceKit = persistenceKitStack.peek();
try {
IEntity model = persistenceKit.readModel(new StreamPersistenceProvider(is));
entity.setContent(CommonsEntityAdapterFactory.createStageUpFragment(ArtifactsEntityDescriptorEnum.Content, model));
} catch (Exception e) {
// TODO parameterize throw new IllegalStateException(e);
}
}
}
use of org.whole.lang.codebase.IPersistenceKit in project whole by wholeplatform.
the class PersistenceLibraryDeployer method derivePersistenceKit.
protected static IPersistenceKit derivePersistenceKit(IBindingManager bm, StringPersistenceProvider pp) {
String persistenceKitId = null;
if (bm.wIsSet("grammarURI")) {
pp.getBindings().wDefValue("grammarURI", bm.wStringValue("grammarURI"));
persistenceKitId = "org.whole.lang.grammars.codebase.GrammarsPersistenceKit";
} else if (bm.wIsSet("persistenceId"))
persistenceKitId = bm.wStringValue("persistenceId");
if (bm.wIsSet("entityURI")) {
String entityURI = bm.wStringValue("entityURI");
pp.getBindings().wDefValue("entityURI", entityURI);
}
if (pp.getBindings().wIsSet("entityURI")) {
String entityURI = pp.getBindings().wStringValue("entityURI");
ILanguageKit languageKit = ResourceUtils.hasFragmentPart(entityURI) ? CommonsDataTypePersistenceParser.getEntityDescriptor(entityURI, true, bm).getLanguageKit() : ReflectionFactory.getLanguageKit(entityURI, true, bm);
if (persistenceKitId == null)
for (IPersistenceKit persistenceKit : languageKit.getPersistenceKits()) if (!persistenceKit.isGeneric()) {
persistenceKitId = persistenceKit.getId();
break;
}
if (persistenceKitId == null)
persistenceKitId = languageKit.getDefaultPersistenceKit().getId();
}
if (persistenceKitId == null)
persistenceKitId = "org.whole.lang.xml.codebase.XmlBuilderPersistenceKit";
if (!ReflectionFactory.hasPersistenceKit(persistenceKitId))
throw new IllegalArgumentException("Missing persistence");
return ReflectionFactory.getPersistenceKit(persistenceKitId);
}
Aggregations