use of org.whole.lang.artifacts.model.Workspace in project whole by wholeplatform.
the class ArtifactsWorkspaceUtils method toArtifactsPath.
public static IEntity toArtifactsPath(IResource fromResource, IResource toResource, IEntity child) {
ArtifactsEntityFactory aef = ArtifactsEntityFactory.instance(RegistryConfigurations.RESOLVER);
IEntity entity;
String name = toResource.getName();
switch(toResource.getType()) {
case IResource.FILE:
FileArtifact fileArtifact = aef.createFileArtifact();
fileArtifact.setName(createFileName(name));
entity = fileArtifact;
break;
case IResource.FOLDER:
FolderArtifact folderArtifact = aef.createFolderArtifact();
folderArtifact.setName(aef.createName(name));
folderArtifact.setArtifacts(aef.createArtifacts(0));
entity = folderArtifact;
break;
case IResource.PROJECT:
Project project = aef.createProject();
project.setName(aef.createName(name));
project.setArtifacts(aef.createArtifacts(0));
entity = project;
break;
default:
case IResource.ROOT:
Workspace workspace = aef.createWorkspace();
workspace.setProjects(aef.createProjects(0));
entity = workspace;
break;
}
boolean isWorkspace = Matcher.match(ArtifactsEntityDescriptorEnum.Workspace, entity);
if (!EntityUtils.isNull(child))
entity.wGet(isWorkspace ? ArtifactsFeatureDescriptorEnum.projects : ArtifactsFeatureDescriptorEnum.artifacts).wAdd(child);
return fromResource.equals(toResource) ? entity : toArtifactsPath(fromResource, toResource.getParent(), entity);
}
use of org.whole.lang.artifacts.model.Workspace in project whole by wholeplatform.
the class ArtifactsWorkspaceUtils method toArtifactsPath.
public static IEntity toArtifactsPath(IJavaElement fromJavaElement, IJavaElement toJavaElement, IEntity child) {
ArtifactsEntityFactory aef = ArtifactsEntityFactory.instance(RegistryConfigurations.RESOLVER);
IEntity entity;
String name = toJavaElement.getElementName();
switch(toJavaElement.getElementType()) {
case IJavaElement.COMPILATION_UNIT:
FileArtifact fileArtifact = aef.createFileArtifact();
fileArtifact.setName(createFileName(name));
entity = fileArtifact;
break;
case IJavaElement.PACKAGE_FRAGMENT:
if (name == IPackageFragment.DEFAULT_PACKAGE_NAME)
return fromJavaElement.equals(toJavaElement) ? child : toArtifactsPath(fromJavaElement, toJavaElement.getParent(), child);
PackageArtifact packageArtifact = aef.createPackageArtifact();
packageArtifact.setName(aef.createName(name));
entity = packageArtifact;
break;
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
FolderArtifact folderArtifact = aef.createFolderArtifact();
Metadata metadata = aef.createMetadata();
metadata.setAttributes(aef.createAttributes(aef.createAttribute(AttributeEnum.source)));
folderArtifact.setMetadata(metadata);
folderArtifact.setName(aef.createName(name));
entity = folderArtifact;
break;
case IJavaElement.JAVA_PROJECT:
Project project = aef.createProject();
project.setName(aef.createName(name));
project.setNatures(aef.createNatures(aef.createNature("org.eclipse.jdt.core.javanature")));
project.setArtifacts(aef.createArtifacts(0));
entity = project;
break;
default:
case IJavaElement.JAVA_MODEL:
Workspace workspace = aef.createWorkspace();
workspace.setProjects(aef.createProjects(0));
entity = workspace;
break;
}
boolean isWorkspace = Matcher.match(ArtifactsEntityDescriptorEnum.Workspace, entity);
if (!EntityUtils.isNull(child))
entity.wGet(isWorkspace ? ArtifactsFeatureDescriptorEnum.projects : ArtifactsFeatureDescriptorEnum.artifacts).wAdd(child);
return fromJavaElement.equals(toJavaElement) ? entity : toArtifactsPath(fromJavaElement, toJavaElement.getParent(), entity);
}
Aggregations