Aller au contenu principal

Speichern eines geänderten Schemas über die Api

Commentaires

1 commentaire

  • Zendesk API User
    Author: stephan - 3/30/2012 10:07

    Hallo Robert,

    eine Lösung könnte z.B. so aussehen:

        // run as contextscript on tabletemplate

        TableTemplate tableTemplate = (TableTemplate) context.getStoreElement();

        Schema _schema = tableTemplate.getSchema();

        String _entityTypeName = "MyTable";

        String _attributeName = "MyAttribute";

         try {

            _schema.setLock(true, false);

            final Session orSession = _schema.getSession(false);

            final de.espirit.or.schema.Schema orSchema = orSession.getSchema();

            final EntityType entityType = orSchema.getEntityType(_entityTypeName);

            SimpleAttribute _attribute = entityType.createSimpleAttribute(_attributeName, String.class);

            _attribute.setSize(64);

            orSession.syncSchemaWithDB(orSchema, false);

            _schema.setOrSchema(orSchema);

            _schema.save();

        } catch (Exception e) {

            throw new RuntimeException(e);

        } finally {

            try {

                _schema.setLock(false, false);

            } catch (Exception ignore) {

                // catch exception

            }

        }

    Was bei dir sicherlich noch fehlte war der Sync des geänderten orSchemas in der aktuellen Session, sowie die Zuweiseung zum Templatestore-Schema.

    Viele Grüße

    Jörg

    0

Vous devez vous connecter pour laisser un commentaire.