@Override public String getNewName() { return (procedure != null) ? procedure.getName() : null; } }
public String getNewName() { return (procedure != null) ? procedure.getName() : null; } }
/** * Adds stored procedure to the list of procedures. If there is another * procedure registered under the same name, throws an * IllegalArgumentException. */ public void addProcedure(Procedure procedure) { if (procedure.getName() == null) { throw new NullPointerException("Attempt to add procedure with no name."); } // TODO: change method signature to return replaced procedure and make // sure the // Modeler handles it... Object existingProcedure = procedureMap.get(procedure.getName()); if (existingProcedure != null) { if (existingProcedure == procedure) { return; } else { throw new IllegalArgumentException("An attempt to override procedure '" + procedure.getName()); } } procedureMap.put(procedure.getName(), procedure); procedure.setDataMap(this); }
/** * Adds stored procedure to the list of procedures. If there is another procedure * registered under the same name, throws an IllegalArgumentException. */ public void addProcedure(Procedure procedure) { if (procedure.getName() == null) { throw new NullPointerException("Attempt to add procedure with no name."); } // TODO: change method signature to return replaced procedure and make sure the // Modeler handles it... Object existingProcedure = procedureMap.get(procedure.getName()); if (existingProcedure != null) { if (existingProcedure == procedure) { return; } else { throw new IllegalArgumentException("An attempt to override procedure '" + procedure.getName()); } } procedureMap.put(procedure.getName(), procedure); procedure.setDataMap(this); }
private void searchInProcedures(Pattern pattern, List<SearchResultEntry> result, DataMap dataMap) { for (Procedure proc : dataMap.getProcedures()) { if (match(proc.getName(), pattern)) { result.add(new SearchResultEntry(proc, proc.getName())); } for(ProcedureParameter param : proc.getCallParameters()) { if(match(param.getName(), pattern)) { result.add(new SearchResultEntry(param, proc.getName() + '.' + param.getName())); } } } }
private boolean syncProcedures(DataMap targetDataMap, DataMap loadedDataMap, FiltersConfig filters) { Collection<Procedure> procedures = loadedDataMap.getProcedures(); if (procedures.isEmpty()) { return false; } boolean hasChanges = false; for (Procedure procedure : procedures) { PatternFilter proceduresFilter = filters.proceduresFilter(procedure.getCatalog(), procedure.getSchema()); if (proceduresFilter == null || !proceduresFilter.isIncluded(procedure.getName())) { continue; } Procedure oldProcedure = targetDataMap.getProcedure(procedure.getName()); // maybe we need to compare oldProcedure's and procedure's fully qualified names? if (oldProcedure != null) { targetDataMap.removeProcedure(procedure.getName()); logger.info("Replace procedure " + procedure.getName()); } else { logger.info("Add new procedure " + procedure.getName()); } targetDataMap.addProcedure(procedure); hasChanges = true; } return hasChanges; }
void validate(Procedure procedure, ValidationResult validationResult) { validateName(procedure, validationResult); // check that return value is present if (procedure.isReturningValue()) { List<ProcedureParameter> parameters = procedure.getCallParameters(); if (parameters.isEmpty()) { addFailure( validationResult, procedure, "Procedure '%s' returns a value, but has no parameters", procedure.getName()); } } }
/** * Creates a ColumnDescriptor from stored procedure parameter. * * @since 1.2 */ public ColumnDescriptor(ProcedureParameter parameter) { this(parameter.getName(), parameter.getType()); if (parameter.getProcedure() != null) { this.procedureName = parameter.getProcedure().getName(); } }
protected void validateRoot( ProcedureQuery query, ProjectPath path, Validator validator) { DataMap map = (DataMap) path.firstInstanceOf(DataMap.class); Object root = query.getRoot(); if (root == null && map != null) { validator.registerWarning("Query has no root", path); } // procedure query only supports procedure root if (root instanceof Procedure) { Procedure procedure = (Procedure) root; // procedure may have been deleted... if (map != null && map.getProcedure(procedure.getName()) != procedure) { validator.registerWarning("Invalid Procedure Root - " + procedure.getName(), path); } return; } if (root instanceof String) { if (map != null && map.getProcedure(root.toString()) == null) { validator.registerWarning("Invalid Procedure Root - " + root, path); } } }
void setProcedureName(String newName) { if (newName != null && newName.trim().length() == 0) { newName = null; } Procedure procedure = eventController.getCurrentProcedure(); if (procedure == null || Util.nullSafeEquals(newName, procedure.getName())) { return; } if (newName == null) { throw new ValidationException("Procedure name is required."); } else if (procedure.getDataMap().getProcedure(newName) == null) { // completely new name, set new name for entity ProcedureEvent e = new ProcedureEvent(this, procedure, procedure.getName()); ProjectUtil.setProcedureName(procedure.getDataMap(), procedure, newName); eventController.fireProcedureEvent(e); } else { // there is an entity with the same name throw new ValidationException("There is another procedure with name '" + newName + "'."); } }
@Override public void saveLastDisplayEvent() { preferences.setEvent(ProcedureDisplayEvent.class.getSimpleName()); preferences.setDomain(controller.getCurrentDataChanel().getName()); preferences.setDataMap(controller.getCurrentDataMap().getName()); preferences.setProcedure(controller.getCurrentProcedure().getName()); }
/** * Invoked when currently selected Procedure object is changed. */ public void currentProcedureChanged(ProcedureDisplayEvent e) { Procedure procedure = e.getProcedure(); if (procedure == null || !e.isProcedureChanged()) { return; } name.setText(procedure.getName()); schema.setText(procedure.getSchema()); catalog.setText(procedure.getCatalog()); ignoreChange = true; returnsValue.setSelected(procedure.isReturningValue()); ignoreChange = false; }
public static void setProcedureName(DataMap map, Procedure procedure, String newName) { String oldName = procedure.getName(); // If name hasn't changed, just return if (Util.nullSafeEquals(oldName, newName)) { return; } procedure.setName(newName); map.removeProcedure(oldName); map.addProcedure(procedure); // important - clear parent namespace: MappingNamespace ns = map.getNamespace(); if (ns instanceof EntityResolver) { ((EntityResolver) ns).refreshMappingCache(); } }
@Override public void saveLastDisplayEvent() { preferences.setEvent(ProcedureParameterDisplayEvent.class.getSimpleName()); preferences.setDomain(controller.getCurrentDataChanel().getName()); preferences.setDataMap(controller.getCurrentDataMap().getName()); preferences.setProcedure(controller.getCurrentProcedure().getName()); preferences.setProcedureParams(parseToString(controller.getCurrentProcedureParameters())); }
/** * Removes current Procedure from its DataMap and fires "remove" ProcedureEvent. */ public void removeProcedure(DataMap map, Procedure procedure) { ProjectController mediator = getProjectController(); ProcedureEvent e = new ProcedureEvent(Application.getFrame(), procedure, MapEvent.REMOVE); e.setDomain((DataChannelDescriptor) mediator.getProject().getRootNode()); map.removeProcedure(procedure.getName()); mediator.fireProcedureEvent(e); }
/** * Creates a ColumnDescriptor from stored procedure parameter. * * @since 1.2 */ public ColumnDescriptor(ProcedureParameter parameter) { this.name = parameter.getName(); this.qualifiedColumnName = name; this.label = name; this.jdbcType = parameter.getType(); this.javaClass = getDefaultJavaClass(parameter.getMaxLength(), parameter .getPrecision()); if (parameter.getProcedure() != null) { this.procedureName = parameter.getProcedure().getName(); } }
/** * Prints itself as XML to the provided XMLEncoder. * * @since 1.1 */ public void encodeAsXML(XMLEncoder encoder) { encoder.print("<procedure name=\""); encoder.print(Util.encodeXmlAttribute(getName())); encoder.print('\"'); if (getSchema() != null && getSchema().trim().length() > 0) { encoder.print(" schema=\""); encoder.print(getSchema().trim()); encoder.print('\"'); } if (getCatalog() != null && getCatalog().trim().length() > 0) { encoder.print(" catalog=\""); encoder.print(getCatalog().trim()); encoder.print('\"'); } if (isReturningValue()) { encoder.print(" returningValue=\"true\""); } encoder.println('>'); encoder.indent(1); encoder.print(getCallParameters()); encoder.indent(-1); encoder.println("</procedure>"); }