Skip to content
This repository has been archived by the owner on Nov 22, 2019. It is now read-only.

Commit

Permalink
TEIIDTOOL-474
Browse files Browse the repository at this point in the history
 * Added ViewDefinition to ViewEditorState framework
 * includes properties and Sql Composition array
 * Commented out the view definition additions to Service tests.
  • Loading branch information
blafond committed Aug 2, 2018
1 parent 9299e70 commit 7937cab
Show file tree
Hide file tree
Showing 21 changed files with 2,185 additions and 26 deletions.
87 changes: 87 additions & 0 deletions komodo-core/src/main/java/org/komodo/core/KomodoLexicon.java
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,93 @@ interface ViewEditorState {
* The name of the view editor state node type. Value is {@value} .
*/
String NODE_TYPE = Namespace.PREFIX + COLON + "viewEditorState"; //$NON-NLS-1$

/**
* The name of the view definition child node. Value is {@value} .
*/
String VIEW_DEFINITION = Namespace.PREFIX + COLON + "viewDefinition"; //$NON-NLS-1$
}

/**
* The JCR names associated with the view definition node type.
*/
interface ViewDefinition {

/**
* The name of the view definition node type. Value is {@value} .
*/
String NODE_TYPE = Namespace.PREFIX + COLON + "viewDefinition"; //$NON-NLS-1$

/**
* The name of the view definition description property. Value is {@value} .
*/
String VIEW_NAME = Namespace.PREFIX + COLON + "viewName"; //$NON-NLS-1$

/**
* The name of the view definition description property. Value is {@value} .
*/
String DESCRIPTION = Namespace.PREFIX + COLON + "description"; //$NON-NLS-1$

/**
* The name of the view definition isComplete property. Value is {@value} .
*/
String IS_COMPLETE = Namespace.PREFIX + COLON + "isComplete"; //$NON-NLS-1$

/**
* The name of the view definition source paths container property. Value is {@value} .
*/
String SOURCE_PATHS = Namespace.PREFIX + COLON + "sourcePaths"; //$NON-NLS-1$

/**
* The name of the sql compositions child node. Value is {@value} .
*/
String SQL_COMPOSITIONS = Namespace.PREFIX + COLON + "sqlCompositions"; //$NON-NLS-1$
}

/**
* The JCR names associated with the view definition node type.
*/
interface SqlComposition {

/**
* The name of the view definition node type. Value is {@value} .
*/
String NODE_TYPE = Namespace.PREFIX + COLON + "sqlComposition"; //$NON-NLS-1$

/**
* The name of the view definition description property. Value is {@value} .
*/
String DESCRIPTION = Namespace.PREFIX + COLON + "description"; //$NON-NLS-1$

/**
* The name of the view definition leftSource property. Value is {@value} .
*/
String LEFT_SOURCE_PATH = Namespace.PREFIX + COLON + "leftSourcePath"; //$NON-NLS-1$

/**
* The name of the view definition rightSource property. Value is {@value} .
*/
String RIGHT_SOURCE_PATH = Namespace.PREFIX + COLON + "rightSourcePath"; //$NON-NLS-1$

/**
* The name of the view definition leftSource property. Value is {@value} .
*/
String LEFT_CRITERIA_COLUMN = Namespace.PREFIX + COLON + "leftCriteriaColumn"; //$NON-NLS-1$

/**
* The name of the view definition rightSource property. Value is {@value} .
*/
String RIGHT_CRITERIA_COLUMN = Namespace.PREFIX + COLON + "rightCriteriaColumn"; //$NON-NLS-1$

/**
* The name of the view definition type property. Value is {@value} .
*/
String TYPE = Namespace.PREFIX + COLON + "type"; //$NON-NLS-1$

/**
* The name of the view definition operator property. Value is {@value} .
*/
String OPERATOR = Namespace.PREFIX + COLON + "operator"; //$NON-NLS-1$
}

/**
Expand Down
25 changes: 25 additions & 0 deletions komodo-core/src/main/resources/config/komodo.cnd
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,31 @@
+ undo (tko:stateCommand)
+ redo (tko:stateCommand)

/*
* a SQL composition
*/
[tko:sqlComposition] > nt:unstructured
- tko:description (string)
- tko:leftNodePath (string)
- tko:rightNodePath (string)
- tko:leftCriteriaColumn (string)
- tko:rightCriteriaColumn (string)
- tko:type (string) < 'INNER_JOIN', 'LEFT_JOIN', 'RIGHT_JOIN', 'FULL_OUTER_JOIN', 'UNION'
- tko:operator (string) < 'EQ', 'NE', 'LT', 'GT', 'LE', 'GE'

[tko:sqlCompositions] > nt:unstructured
+ * (tko:sqlComposition) copy

/*
* the view definition containing properties and command for a view
*/
[tko:viewDefinition] > nt:unstructured
- tko:viewName (string)
- tko:description (string)
- tko:isComplete (boolean) = 'false' mandatory
- tko:sourcePaths (string) multiple
+ tko:sqlCompositions (tko:sqlCompositions)

/*
* The state of a view editor when saved
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,26 @@ public enum Relational {
* An error indicating a view editor state object could not be found
* while trying to remove it
*/
VIEW_EDITOR_STATE_NOT_FOUND_TO_REMOVE;
VIEW_EDITOR_STATE_NOT_FOUND_TO_REMOVE,

/**
* An error indicating a sql composition object could not be found
* while trying to remove it
*/
SQL_COMPOSITION_NOT_FOUND_TO_REMOVE,


/**
* An error indicating a source path already exists in the list
* while trying to add it
*/
DUPLICATE_SOURCE_PATH,

/**
* An error indicating a source path could not be found
* while trying to remove it
*/
SOURCE_PATH_NOT_FOUND_TO_REMOVE;

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@
import org.komodo.relational.model.internal.VirtualProcedureImpl;
import org.komodo.relational.profile.GitRepository;
import org.komodo.relational.profile.Profile;
import org.komodo.relational.profile.SqlComposition;
import org.komodo.relational.profile.StateCommand;
import org.komodo.relational.profile.ViewEditorState;
import org.komodo.relational.profile.StateCommandAggregate;
import org.komodo.relational.profile.ViewDefinition;
import org.komodo.relational.profile.internal.GitRepositoryImpl;
import org.komodo.relational.profile.internal.SqlCompositionImpl;
import org.komodo.relational.profile.internal.StateCommandAggregateImpl;
import org.komodo.relational.profile.internal.ViewEditorStateImpl;
import org.komodo.relational.profile.internal.ViewDefinitionImpl;
import org.komodo.relational.resource.DdlFile;
import org.komodo.relational.resource.Driver;
import org.komodo.relational.resource.ResourceFile;
Expand Down Expand Up @@ -1725,6 +1729,84 @@ public static ViewEditorState createViewEditorState(UnitOfWork transaction, Repo
throw handleError( e );
}
}

/**
*
* @param transaction
* the transaction (cannot be <code>null</code> or have a state that is not {@link State#NOT_STARTED})
* @param repository
* the repository where the model object will be created (cannot be <code>null</code>)
* @param profile
* the parent profile object
* @param stateId
* the id of the view definition
* @return the view definition object
* @throws KException
* if an error occurs
*/
public static ViewDefinition createViewDefinition(UnitOfWork transaction, Repository repository, ViewEditorState viewEditorState) throws KException {
ArgCheck.isNotNull( transaction, "transaction" ); //$NON-NLS-1$
ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); //$NON-NLS-1$
ArgCheck.isNotNull( repository, "repository" ); //$NON-NLS-1$

try {
final KomodoObject grouping = RepositoryTools.findOrCreateChild( transaction,
viewEditorState,
KomodoLexicon.ViewEditorState.VIEW_DEFINITION,
KomodoLexicon.ViewEditorState.VIEW_DEFINITION );
final KomodoObject kobject = grouping.addChild( transaction, "view-definitin", KomodoLexicon.ViewDefinition.NODE_TYPE );
final ViewDefinition result = new ViewDefinitionImpl( transaction, repository, kobject.getAbsolutePath() );
return result;
} catch ( final Exception e ) {
throw handleError( e );
}
}

/**
*
* @param transaction
* the transaction (cannot be <code>null</code> or have a state that is not {@link State#NOT_STARTED})
* @param repository
* the repository where the model object will be created (cannot be <code>null</code>)
* @param viewDefinitionImpl
* the parent profile object
* @param compositionName
* the sql composition name
* @param description
* the description
* @param leftSourcePath
* the path to the left source table
* @param rightSourcePath
* the path to the right source table
* @param type
* the composition type
* @param operator
* the operator for the criteria
* @return the sql composition object
* @throws KException
* if an error occurs
*/
public static SqlComposition createSqlComposition(UnitOfWork transaction, Repository repository,
ViewDefinition viewDefinition, String compositionName, String description, String leftSourcePath,
String rightSourcePath, String type, String operator) throws KException {

ArgCheck.isNotNull( transaction, "transaction" ); //$NON-NLS-1$
ArgCheck.isTrue( ( transaction.getState() == State.NOT_STARTED ), "transaction state is not NOT_STARTED" ); //$NON-NLS-1$
ArgCheck.isNotNull( repository, "repository" ); //$NON-NLS-1$
ArgCheck.isNotNull( compositionName, "compositionName" ); //$NON-NLS-1$

try {
final KomodoObject grouping = RepositoryTools.findOrCreateChild( transaction,
viewDefinition,
KomodoLexicon.ViewDefinition.SQL_COMPOSITIONS,
KomodoLexicon.ViewDefinition.SQL_COMPOSITIONS );
final KomodoObject kobject = grouping.addChild( transaction, compositionName, KomodoLexicon.SqlComposition.NODE_TYPE );
final SqlComposition result = new SqlCompositionImpl( transaction, repository, kobject.getAbsolutePath() );
return result;
} catch ( final Exception e ) {
throw handleError( e );
}
}

/**
*
Expand Down

0 comments on commit 7937cab

Please sign in to comment.