/** * Writes to *.dbschema file from schema * @param schema a SchemaElement * @param filePath a directory where *.dbschema is located * @throws IOException */ private static void writeSchemaFile(SchemaElement schema, File filePath) throws IOException { OutputStream schemaStream = null; try { schemaStream = new FileOutputStream( new File(filePath, NameUtil.getSchemaResourceName( schema.getName().getName()))); schema.save(schemaStream); } catch (IOException ex) { throw ex; } finally { try { if (schemaStream != null) { schemaStream.close(); } } catch (IOException ex) { if (logger.isLoggable(Logger.FINE)) logger.fine(ex.toString()); } } }
if (null != classLoader) { if (loadedSchema.get(schemaElementValue) == null) { SchemaElement.removeFromCache(schemaElementValue); loadedSchema.put(schemaElementValue, schemaElementValue); bar = SchemaElement.forName(schemaElementValue,classLoader); bar = SchemaElement.forName(schemaElementValue); if (strict) { if (bar == null) { bar = new SchemaElement(); DBIdentifier n = DBIdentifier.create(schemaElementValue); n.setFullName(schemaElementValue); bar.setName(n);
/** * Get the primary table element for the mapping class. * @param mappingClass That which is associated with the table. * @return Table that is associated with mapping class. * @throws DBException */ private TableElement getPrimaryTable(MappingClassElement mappingClass) throws DBException { List tables = mappingClass.getTables(); MappingTableElement tbl = (MappingTableElement) tables.get(0); if (tbl != null) { DBIdentifier tblName = DBIdentifier.create(tbl.getTable()); return schema.getTable(tblName); } else { return null; } }
/** * Creates and returns a schema from give schema name * @param schemaName A name for schema. * @return Newly created schema element. * @throws DBException */ static SchemaElement createSchema(String schemaName) throws DBException { SchemaElementImpl schemaImpl = new SchemaElementImpl(); SchemaElement schema = new SchemaElement(schemaImpl); schema.setName(DBIdentifier.create(schemaName)); schema.setDatabaseProductVersion(TAGLINE + SIGNATURE); return schema; }
SchemaElement fakeSchema = new SchemaElement(new SchemaElementImpl()); fakeSchema.setName(DBIdentifier.create(FAKE_NAME)); SchemaElement.addToCache(fakeSchema); SchemaElement.removeFromCache(FAKE_NAME); SchemaElement.removeFromCache(schema.getName().getName()); SchemaElement.addToCache(schema);
SchemaElement se = new SchemaElement(outSchemaImpl); se.setName(DBIdentifier.create(bundle.getString("STRING_SCHEMAS_SLASH_NOI18N") + dbschemaname));//NOI18N else se.setName(DBIdentifier.create("")); //NOI18N se.save(outstream);
/** Set the database root for this MappingClassElement. * The root represents the database used by the tables mapped to * this mapping class. * @param root the new database root * @exception ModelException if impossible */ public void setDatabaseRoot (SchemaElement root) throws ModelException { String old = getDatabaseRoot(); String newRoot = ((root != null) ? root.getName().getFullName() : null); try { fireVetoableChange(PROP_DATABASE_ROOT, old, newRoot); _databaseRoot = newRoot; firePropertyChange(PROP_DATABASE_ROOT, old, newRoot); } catch (PropertyVetoException e) { throw new ModelVetoException(e); } }
/** Gets the schema with the specified name, loading it if necessary. * This implementation uses the class loader as the extra context * information used to load. * @param schemaName the name of the schema to be loaded * @return the schema object */ public SchemaElement getSchema(String schemaName) { return SchemaElement.forName(schemaName, getClassLoader()); }
/** * Create table and add to schema. * @param schema Schema to which the table gets attached. * @param tableName Name of the table without the schema name. * @return TableElement for this table name * @throws DBException */ static TableElement createAndAttachTable(SchemaElement schema, String tableName) throws DBException { String fullName = NameUtil.getAbsoluteTableName( schema.getName().getName(), tableName); TableElementImpl tableImpl = new TableElementImpl(tableName); TableElement table = new TableElement(tableImpl, schema); table.setName(DBIdentifier.create(fullName)); table.setTableOrView(true); schema.addTable(table); return table; }
SchemaElement.removeFromCache(mapping.getDatabaseRoot());
SchemaElement schemaElement = new SchemaElement(outSchemaImpl); schemaElement.setName(DBIdentifier.create(generatedSchemaName)); schemaElement.save(outstream);
/** Set the database root for this MappingClassElement. * The root represents the database used by the tables mapped to * this mapping class. * @param root the new database root * @exception ModelException if impossible */ public void setDatabaseRoot (SchemaElement root) throws ModelException { String old = getDatabaseRoot(); String newRoot = ((root != null) ? root.getName().getFullName() : null); try { fireVetoableChange(PROP_DATABASE_ROOT, old, newRoot); _databaseRoot = newRoot; firePropertyChange(PROP_DATABASE_ROOT, old, newRoot); } catch (PropertyVetoException e) { throw new ModelVetoException(e); } }
public void validate () throws ModelValidationException { String schemaName = getSchemaForClass(className); if ((schemaName != null) && (SchemaElement.forName(schemaName) == null)) { Object[] args = (relatedField == null) ? new Object[]{schemaName, className} : new Object[]{schemaName, className, relatedField}; throw new ModelValidationException( ModelValidationException.WARNING, getOffendingObject(relatedField), I18NHelper.getMessage(getMessages(), getKey( "util.validation.schema_not_found", //NOI18N relatedField), args)); } } };
SchemaElement.removeFromCache(mapping.getDatabaseRoot());
else if (!currentRoot.equals(schema.getName().getFullName()))
public void validate () throws ModelValidationException { String schemaName = getSchemaForClass(className); if ((schemaName != null) && (SchemaElement.forName(schemaName) == null)) { Object[] args = (relatedField == null) ? new Object[]{schemaName, className} : new Object[]{schemaName, className, relatedField}; throw new ModelValidationException( ModelValidationException.WARNING, getOffendingObject(relatedField), I18NHelper.getMessage(getMessages(), getKey( "util.validation.schema_not_found", //NOI18N relatedField), args)); } } };
schema.getTable(dbId) : null);
else if (!currentRoot.equals(schema.getName().getFullName()))
(SchemaElement.forName(databaseRoot, classLoader) == null))