/** * INTERNAL: * Prepare the receiver for execution in a session. */ @Override public void prepareForExecution() throws QueryException { super.prepareForExecution(); this.containerPolicy.prepareForExecution(); // Modifying the translation row here will modify it on the original // query which is not good. So we have to clone the translation row if // we are going to append tenant discriminator fields to it. if (descriptor.hasMultitenantPolicy()) { translationRow = translationRow.clone(); descriptor.getMultitenantPolicy().addFieldsToRow(translationRow, getSession()); } }
private String getContext(AbstractSession writeSession) { String context = "default"; if (writeSession != null) { MultitenantPolicy policy = writeSession.getProject().getMultitenantPolicy(); if (policy != null && policy.isSchemaPerMultitenantPolicy()) { SchemaPerMultitenantPolicy tableMtPolicy = (SchemaPerMultitenantPolicy) policy; if (tableMtPolicy.isSchemaPerTable()) { String tenantContext = (String) writeSession.getProperty(tableMtPolicy.getContextProperty()); if (tenantContext != null) { context = tenantContext; } } } } return context; } }
/** * PUBLIC * @return true if this descriptor is configured with a table per tenant policy. */ public boolean hasTablePerMultitenantPolicy() { return hasMultitenantPolicy() && getMultitenantPolicy().isTablePerMultitenantPolicy(); }
clonedDescriptor.setMultitenantPolicy(getMultitenantPolicy().clone(clonedDescriptor));
getProject().getMultitenantPolicy().initialize(this);
descriptor.getMultitenantPolicy().addToTableDefinition(getTableDefFromDBTable(descriptor.getDefaultTable()));
getMultitenantPolicy().preInitialize(session);
getMultitenantPolicy().postInitialize(session);
/** * INTERNAL: * Indicates if single table multitenant metadata has been processed for * this descriptor. */ public boolean hasSingleTableMultitenant() { return hasMultitenant() && m_descriptor.getMultitenantPolicy().isSingleTableMultitenantPolicy(); }
MultitenantPolicy clonedMultitenantPolicy = (MultitenantPolicy) getParentDescriptor().getMultitenantPolicy().clone(getDescriptor()); getDescriptor().setMultitenantPolicy(clonedMultitenantPolicy);
getProject().getMultitenantPolicy().initialize(this);
descriptor.getMultitenantPolicy().addToTableDefinition(getTableDefFromDBTable(descriptor.getDefaultTable()));
getMultitenantPolicy().preInitialize(session);
getMultitenantPolicy().postInitialize(session);
/** * INTERNAL: * Prepare the receiver for execution in a session. */ @Override public void prepareForExecution() throws QueryException { super.prepareForExecution(); this.containerPolicy.prepareForExecution(); // Modifying the translation row here will modify it on the original // query which is not good. So we have to clone the translation row if // we are going to append tenant discriminator fields to it. if (descriptor.hasMultitenantPolicy()) { translationRow = translationRow.clone(); descriptor.getMultitenantPolicy().addFieldsToRow(translationRow, getSession()); } }
MultitenantPolicy clonedMultitenantPolicy = (MultitenantPolicy) getParentDescriptor().getMultitenantPolicy().clone(getDescriptor()); getDescriptor().setMultitenantPolicy(clonedMultitenantPolicy);
private String getContext(AbstractSession writeSession) { String context = "default"; if (writeSession != null) { MultitenantPolicy policy = writeSession.getProject().getMultitenantPolicy(); if (policy != null && policy.isSchemaPerMultitenantPolicy()) { SchemaPerMultitenantPolicy tableMtPolicy = (SchemaPerMultitenantPolicy) policy; if (tableMtPolicy.isSchemaPerTable()) { String tenantContext = (String) writeSession.getProperty(tableMtPolicy.getContextProperty()); if (tenantContext != null) { context = tenantContext; } } } } return context; } }
getMultitenantPolicy().initialize(session);
/** * PUBLIC * @return true if this descriptor is configured with a table per tenant policy. */ public boolean hasTablePerMultitenantPolicy() { return hasMultitenantPolicy() && getMultitenantPolicy().isTablePerMultitenantPolicy(); }
/** * Build the row representation of an object. * This is only used for aggregates. */ public AbstractRecord buildRowWithChangeSet(AbstractRecord databaseRow, ObjectChangeSet objectChangeSet, AbstractSession session, WriteType writeType) { List<ChangeRecord> changes = (List)objectChangeSet.getChanges(); int size = changes.size(); for (int index = 0; index < size; index++) { ChangeRecord changeRecord = changes.get(index); DatabaseMapping mapping = changeRecord.getMapping(); mapping.writeFromObjectIntoRowWithChangeRecord(changeRecord, databaseRow, session, writeType); } // If this descriptor is involved in inheritance add the class type. if (this.descriptor.hasInheritance()) { this.descriptor.getInheritancePolicy().addClassIndicatorFieldToRow(databaseRow); } // If the session uses multi-tenancy, add the tenant id field. if (getDescriptor().hasMultitenantPolicy()) { getDescriptor().getMultitenantPolicy().addFieldsToRow(databaseRow, session); } return databaseRow; }