Skip to content

Commit

Permalink
TEIIDDES-1479 added 'import-vdb-reference' property to models that re…
Browse files Browse the repository at this point in the history
…ference re-use vdbs
  • Loading branch information
blafond committed Sep 17, 2012
1 parent 07bcf1e commit 49aa55f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ public void addModels( final List<IFile> models ) {
modelsGroup.getTable().getViewer().refresh();
pnlTranslatorOverrides.refresh();
packModelsGroup();

showImportVdbsButton.setEnabled(!getVdb().getImportVdbEntries().isEmpty());
}

private void packModelsGroup() {
Expand Down Expand Up @@ -1339,6 +1341,8 @@ public void createPartControl( final Composite parent ) {
sash.setWeights(new int[] {50, 50});

ModelerCore.getWorkspace().addResourceChangeListener(this);

showImportVdbsButton.setEnabled(!getVdb().getImportVdbEntries().isEmpty());
}

private void createEditorTop( Composite parent ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public static String createDefaultJndiName(IPath path) {
private final AtomicBoolean visible = new AtomicBoolean(true);
private final CopyOnWriteArraySet<VdbModelEntry> imports = new CopyOnWriteArraySet<VdbModelEntry>();
private final CopyOnWriteArraySet<VdbModelEntry> importedBy = new CopyOnWriteArraySet<VdbModelEntry>();
private final CopyOnWriteArraySet<String> importVdbNames = new CopyOnWriteArraySet<String>();
private final String modelClass;
private final boolean builtIn;
private final String type;
Expand Down Expand Up @@ -176,10 +177,15 @@ public static String createDefaultJndiName(IPath path) {
if (ModelElement.BUILT_IN.equals(name)) builtIn = Boolean.parseBoolean(property.getValue());
else if (ModelElement.INDEX_NAME.equals(name)) indexName = property.getValue();
else if (ModelElement.MODEL_CLASS.equals(name)) modelClass = property.getValue();
else if (ModelElement.IMPORT_VDB_REFERENCE.equals(name)) {
importVdbNames.add(property.getValue());
}
}
this.builtIn = builtIn;
this.indexName = indexName;
this.modelClass = modelClass;

getVdb().registerImportVdbs(importVdbNames, this.getName().toString(), monitor);
}

private void clean() {
Expand Down Expand Up @@ -265,6 +271,14 @@ public final Set<VdbModelEntry> getImportedBy() {
public final Set<VdbModelEntry> getImports() {
return Collections.unmodifiableSet(imports);
}

/**
* @return the immutable set of VDB name strings referenced by this model entry
*/
public final Set<String> getImportVdbNames() {
return Collections.unmodifiableSet(importVdbNames);
}


private File getIndexFile() {
return new File(getVdb().getFolder(), INDEX_FOLDER + indexName);
Expand Down Expand Up @@ -540,8 +554,8 @@ void synchronizeModelEntry( final IProgressMonitor monitor ) {
}
// Also add imported models if not a preview
if (!getVdb().isPreview()) {
importVdbNames.clear();
Resource[] refs = getFinder().findReferencesFrom(model, true, false);
Set<String> importVdbNames = new HashSet<String>();
if (refs != null) {
for (final Resource importedModel : refs) {
java.net.URI uri = java.net.URI.create(importedModel.getURI().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public class ModelElement extends EntryElement {
/**
*/
public static final String IMPORTS = "imports"; //$NON-NLS-1$

/**
*/
public static final String IMPORT_VDB_REFERENCE = "import-vdb-reference"; //$NON-NLS-1$

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -89,6 +93,8 @@ public ModelElement() {
props.add(new PropertyElement(INDEX_NAME, entry.getIndexName()));
for (final VdbModelEntry importedEntry : entry.getImports())
props.add(new PropertyElement(IMPORTS, importedEntry.getName().toString()));
for (final String importedVdbName : entry.getImportVdbNames())
props.add(new PropertyElement(IMPORT_VDB_REFERENCE, importedVdbName));
}

/**
Expand Down

0 comments on commit 49aa55f

Please sign in to comment.