/** * PUBLIC: * Create a new login. */ public DatasourceLogin() { this(new DatasourcePlatform()); }
/** * Get default sequence */ public Sequence getDefaultSequence() { if (!hasDefaultSequence()) { setDefaultSequence(createPlatformDefaultSequence()); } return defaultSequence; }
/** * Add sequence corresponding to the name */ public void addSequence(Sequence sequence) { if (getSequences() == null) { createSequences(); } getSequences().put(sequence.getName(), sequence); }
/** * INTERNAL: * Used only for writing into XML or Java. */ public Sequence getDefaultSequenceToWrite() { if (usesPlatformDefaultSequence()) { return null; } else { return getDefaultSequence(); } }
protected synchronized void createSequences() { if (getSequences() == null) { setSequences(new HashMap()); } }
/** * Copy the state into the new platform. */ public void copyInto(Platform platform) { if (!(platform instanceof DatasourcePlatform)) { return; } DatasourcePlatform datasourcePlatform = (DatasourcePlatform)platform; datasourcePlatform.setTableQualifier(getTableQualifier()); datasourcePlatform.setTimestampQuery(this.timestampQuery); datasourcePlatform.setConversionManager(getConversionManager()); if (hasDefaultSequence()) { datasourcePlatform.setDefaultSequence(getDefaultSequence()); } datasourcePlatform.setSequences(getSequences()); datasourcePlatform.sequencesAfterCloneCleanup(); }
/** * INTERNAL: * Adds descriptors plus sequencing info found on the project to the session. */ protected void addProjectToSession(ServerSession session, Project project) { DatasourcePlatform sessionPlatform = (DatasourcePlatform)session.getDatasourceLogin().getDatasourcePlatform(); DatasourcePlatform projectPlatform = (DatasourcePlatform)project.getDatasourceLogin().getDatasourcePlatform(); if (!sessionPlatform.hasDefaultSequence() && projectPlatform.hasDefaultSequence()) { sessionPlatform.setDefaultSequence(projectPlatform.getDefaultSequence()); } if ((sessionPlatform.getSequences() == null) || sessionPlatform.getSequences().isEmpty()) { if ((projectPlatform.getSequences() != null) && !projectPlatform.getSequences().isEmpty()) { sessionPlatform.setSequences(projectPlatform.getSequences()); } } else { if ((projectPlatform.getSequences() != null) && !projectPlatform.getSequences().isEmpty()) { Iterator itProjectSequences = projectPlatform.getSequences().values().iterator(); while (itProjectSequences.hasNext()) { Sequence sequence = (Sequence)itProjectSequences.next(); if (!sessionPlatform.getSequences().containsKey(sequence.getName())) { sessionPlatform.addSequence(sequence); } } } } session.addDescriptors(project); }
/** * INTERNAL: * Indicates whether defaultSequence is the same as platform default sequence. */ public boolean usesPlatformDefaultSequence() { if (!hasDefaultSequence()) { return true; } else { return getDefaultSequence().equals(createPlatformDefaultSequence()); } } }
/** * Get sequence corresponding to the name */ public Sequence getSequence(String seqName) { if (seqName == null) { return getDefaultSequence(); } else { if (getSequences() != null) { return (Sequence)getSequences().get(seqName); } else { return null; } } }
/** * Convert the object to the appropriate type by invoking the appropriate * ConversionManager method * @param object - the object that must be converted * @param javaClass - the class that the object must be converted to * @exception - ConversionException, all exceptions will be thrown as this type. * @return - the newly converted object */ public Object convertObject(Object sourceObject, Class javaClass) throws ConversionException { return getConversionManager().convertObject(sourceObject, javaClass); }
/** * Remove sequence corresponding to name. * Doesn't remove default sequence. */ public Sequence removeSequence(String seqName) { if (getSequences() != null) { return (Sequence)getSequences().remove(seqName); } else { return null; } }
/** * Return the operator for the operator constant defined in ExpressionOperator. */ public ExpressionOperator getOperator(int selector) { return (ExpressionOperator)getPlatformOperators().get(new Integer(selector)); }
public int getSequencePreallocationSize() { return getDefaultSequence().getPreallocationSize(); }
addOperator(ExpressionOperator.equalOuterJoin()); addOperator(ExpressionOperator.toUpperCase()); addOperator(ExpressionOperator.toLowerCase()); addOperator(ExpressionOperator.chr()); addOperator(ExpressionOperator.concat()); addOperator(ExpressionOperator.hexToRaw()); addOperator(ExpressionOperator.initcap()); addOperator(ExpressionOperator.instring()); addOperator(ExpressionOperator.soundex()); addOperator(ExpressionOperator.leftPad()); addOperator(ExpressionOperator.leftTrim()); addOperator(ExpressionOperator.leftTrim2()); addOperator(ExpressionOperator.replace()); addOperator(ExpressionOperator.rightPad()); addOperator(ExpressionOperator.rightTrim()); addOperator(ExpressionOperator.rightTrim2()); addOperator(ExpressionOperator.substring()); addOperator(ExpressionOperator.toNumber()); addOperator(ExpressionOperator.toChar()); addOperator(ExpressionOperator.toCharWithFormat()); addOperator(ExpressionOperator.translate()); addOperator(ExpressionOperator.trim()); addOperator(ExpressionOperator.trim2()); addOperator(ExpressionOperator.ascii()); addOperator(ExpressionOperator.length()); addOperator(ExpressionOperator.locate()); addOperator(ExpressionOperator.locate2());
/** * Set default sequence. In case the passed sequence is of type DefaultSequence - use platformDefaultSequence * with name and size of the passed sequence. */ public void setDefaultSequence(Sequence sequence) { if (sequence instanceof DefaultSequence) { Sequence platformDefaultSequence = createPlatformDefaultSequence(); if (platformDefaultSequence != null) { platformDefaultSequence.setName(sequence.getName()); if (((DefaultSequence)sequence).hasPreallocationSize()) { platformDefaultSequence.setPreallocationSize(sequence.getPreallocationSize()); } } defaultSequence = platformDefaultSequence; } else { defaultSequence = sequence; } }
/** * Copy the state into the new platform. */ public void copyInto(Platform platform) { super.copyInto(platform); if (!(platform instanceof DatabasePlatform)) { return; } DatabasePlatform databasePlatform = (DatabasePlatform)platform; databasePlatform.setShouldTrimStrings(shouldTrimStrings()); databasePlatform.setUsesNativeSQL(usesNativeSQL()); databasePlatform.setUsesByteArrayBinding(usesByteArrayBinding()); databasePlatform.setUsesStringBinding(usesStringBinding()); databasePlatform.setShouldBindAllParameters(shouldBindAllParameters()); databasePlatform.setShouldCacheAllStatements(shouldCacheAllStatements()); databasePlatform.setStatementCacheSize(getStatementCacheSize()); databasePlatform.setTransactionIsolation(getTransactionIsolation()); databasePlatform.setShouldForceFieldNamesToUpperCase(shouldForceFieldNamesToUpperCase()); databasePlatform.setShouldOptimizeDataConversion(shouldOptimizeDataConversion()); databasePlatform.setStringBindingSize(getStringBindingSize()); databasePlatform.setUsesStreamsForBinding(usesStreamsForBinding()); }
protected void sequencesAfterCloneCleanup() { Sequence defaultSequenceClone = null; if (hasDefaultSequence()) { defaultSequenceClone = (Sequence)getDefaultSequence().clone(); setDefaultSequence(defaultSequenceClone); } HashMap sequencesDeepClone = null; if (getSequences() != null) { sequencesDeepClone = new HashMap(getSequences().size()); Iterator it = getSequences().values().iterator(); while (it.hasNext()) { Sequence sequence = (Sequence)it.next(); if ((defaultSequenceClone != null) && (sequence == getDefaultSequence())) { sequencesDeepClone.put(defaultSequenceClone.getName(), defaultSequenceClone); } else { Sequence sequenceClone = (Sequence)sequence.clone(); if (sequenceClone instanceof DefaultSequence) { if (!((DefaultSequence)sequenceClone).hasPreallocationSize()) { continue; } } sequencesDeepClone.put(sequenceClone.getName(), sequenceClone); } } this.setSequences(sequencesDeepClone); } }
/** * PUBLIC: * Return the list of Classes that can be converted to from the passed in javaClass. * @param javaClass - the class that is converted from * @return - a vector of classes */ public Vector getDataTypesConvertedFrom(Class javaClass) { return getConversionManager().getDataTypesConvertedFrom(javaClass); }
/** * INTERNAL: * Used only for writing into XML or Java. */ public Map getSequencesToWrite() { if ((getSequences() == null) || getSequences().isEmpty()) { return null; } Map sequencesToWrite = new HashMap(); Iterator it = getSequences().values().iterator(); while (it.hasNext()) { Sequence sequence = (Sequence)it.next(); if (!(sequence instanceof DefaultSequence) || ((DefaultSequence)sequence).hasPreallocationSize()) { sequencesToWrite.put(sequence.getName(), sequence); } } return sequencesToWrite; }
/** * PUBLIC: * Return the list of Classes that can be converted from to the passed in javaClass. * @param javaClass - the class that is converted to * @return - a vector of classes */ public Vector getDataTypesConvertedTo(Class javaClass) { return getConversionManager().getDataTypesConvertedTo(javaClass); }