Search in sources :

Example 1 with FileArtifact

use of org.whole.lang.artifacts.model.FileArtifact 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);
}
Also used : ArtifactsEntityFactory(org.whole.lang.artifacts.factories.ArtifactsEntityFactory) Project(org.whole.lang.artifacts.model.Project) IProject(org.eclipse.core.resources.IProject) IEntity(org.whole.lang.model.IEntity) FileArtifact(org.whole.lang.artifacts.model.FileArtifact) FolderArtifact(org.whole.lang.artifacts.model.FolderArtifact) Workspace(org.whole.lang.artifacts.model.Workspace)

Example 2 with FileArtifact

use of org.whole.lang.artifacts.model.FileArtifact in project whole by wholeplatform.

the class ArtifactsWorkspaceUtils method toArtifactsPath.

public static IEntity toArtifactsPath(IJavaElement fromJavaElement, IResource toResource) {
    ArtifactsEntityFactory aef = ArtifactsEntityFactory.instance(RegistryConfigurations.RESOLVER);
    Artifact child;
    if (toResource.getType() == IResource.FILE) {
        FileArtifact fileArtifact = aef.createFileArtifact();
        fileArtifact.setName(createFileName(toResource.getName()));
        child = fileArtifact;
    } else {
        FolderArtifact folderArtifact = aef.createFolderArtifact();
        folderArtifact.setName(aef.createName(toResource.getName()));
        child = folderArtifact;
    }
    return toArtifactsPath(fromJavaElement, JavaCore.create(toResource.getParent()), child);
}
Also used : ArtifactsEntityFactory(org.whole.lang.artifacts.factories.ArtifactsEntityFactory) FileArtifact(org.whole.lang.artifacts.model.FileArtifact) FolderArtifact(org.whole.lang.artifacts.model.FolderArtifact) FileArtifact(org.whole.lang.artifacts.model.FileArtifact) Artifact(org.whole.lang.artifacts.model.Artifact) PackageArtifact(org.whole.lang.artifacts.model.PackageArtifact) FolderArtifact(org.whole.lang.artifacts.model.FolderArtifact)

Example 3 with FileArtifact

use of org.whole.lang.artifacts.model.FileArtifact in project whole by wholeplatform.

the class ArtifactsWorkspaceUtils method appendFileArtifact.

protected static void appendFileArtifact(String nameWithExtension, IEntity children) {
    ArtifactsEntityFactory aef = ArtifactsEntityFactory.instance(RegistryConfigurations.RESOLVER);
    FileArtifact fileArtifact = aef.createFileArtifact();
    fileArtifact.setName(createFileName(nameWithExtension));
    children.wAdd(fileArtifact);
}
Also used : ArtifactsEntityFactory(org.whole.lang.artifacts.factories.ArtifactsEntityFactory) FileArtifact(org.whole.lang.artifacts.model.FileArtifact)

Example 4 with FileArtifact

use of org.whole.lang.artifacts.model.FileArtifact in project whole by wholeplatform.

the class FileArtifactPart method getModelSpecificChildren.

protected List<IEntity> getModelSpecificChildren() {
    FileArtifact entity = getModelEntity();
    List<IEntity> list = new ArrayList<IEntity>(3);
    list.add(entity.getName());
    list.add(entity.getMetadata());
    list.add(entity.getContent());
    return list;
}
Also used : IEntity(org.whole.lang.model.IEntity) FileArtifact(org.whole.lang.artifacts.model.FileArtifact) ArrayList(java.util.ArrayList)

Example 5 with FileArtifact

use of org.whole.lang.artifacts.model.FileArtifact in project whole by wholeplatform.

the class ArtifactsUtils method moveArtifactsIntoWorkspace.

public static void moveArtifactsIntoWorkspace(IEntity artifacts, IBindingManager bm) {
    switch(artifacts.wGetEntityDescriptor().getOrdinal()) {
        case ArtifactsEntityDescriptorEnum.Workspace_ord:
            Projects projectsPoint = (Projects) bm.wGet("projectsPoint");
            if (projectsPoint == null)
                throw new IllegalArgumentException("projectsPoint is undefined");
            IEntityIterator<Project> projectIterator = IteratorFactory.childIterator();
            projectIterator.reset(((Workspace) artifacts).getProjects());
            for (Project project : projectIterator) {
                projectIterator.remove();
                projectsPoint.add(project);
            }
            break;
        case ArtifactsEntityDescriptorEnum.Artifacts_ord:
            Artifacts packagesPoint = (Artifacts) bm.wGet("packagesPoint");
            if (packagesPoint == null)
                throw new IllegalArgumentException("packagesPoint is undefined");
            IEntityIterator<Artifact> artifactIterator = IteratorFactory.childIterator();
            artifactIterator.reset(artifacts);
            for (Artifact artifact : artifactIterator) {
                artifactIterator.remove();
                packagesPoint.add(artifact);
            }
            break;
        case ArtifactsEntityDescriptorEnum.PackageArtifact_ord:
        case ArtifactsEntityDescriptorEnum.FolderArtifact_ord:
            packagesPoint = (Artifacts) bm.wGet("packagesPoint");
            if (packagesPoint == null)
                throw new IllegalArgumentException("packagesPoint is undefined");
            packagesPoint.add((Artifact) artifacts);
            break;
        case ArtifactsEntityDescriptorEnum.FileArtifact_ord:
            Artifacts packageArtifactsPoint = (Artifacts) bm.wGet("packageArtifactsPoint");
            if (packageArtifactsPoint == null)
                throw new IllegalArgumentException("packageArtifactsPoint is undefined");
            packageArtifactsPoint.add((FileArtifact) artifacts);
            break;
    }
}
Also used : Project(org.whole.lang.artifacts.model.Project) Artifacts(org.whole.lang.artifacts.model.Artifacts) Projects(org.whole.lang.artifacts.model.Projects) Artifact(org.whole.lang.artifacts.model.Artifact) FileArtifact(org.whole.lang.artifacts.model.FileArtifact) PackageArtifact(org.whole.lang.artifacts.model.PackageArtifact) FolderArtifact(org.whole.lang.artifacts.model.FolderArtifact) FileArtifact(org.whole.lang.artifacts.reflect.ArtifactsEntityDescriptorEnum.FileArtifact)

Aggregations

FileArtifact (org.whole.lang.artifacts.model.FileArtifact)6 ArtifactsEntityFactory (org.whole.lang.artifacts.factories.ArtifactsEntityFactory)4 FolderArtifact (org.whole.lang.artifacts.model.FolderArtifact)4 PackageArtifact (org.whole.lang.artifacts.model.PackageArtifact)3 Project (org.whole.lang.artifacts.model.Project)3 IEntity (org.whole.lang.model.IEntity)3 IProject (org.eclipse.core.resources.IProject)2 Artifact (org.whole.lang.artifacts.model.Artifact)2 Workspace (org.whole.lang.artifacts.model.Workspace)2 ArrayList (java.util.ArrayList)1 Artifacts (org.whole.lang.artifacts.model.Artifacts)1 Metadata (org.whole.lang.artifacts.model.Metadata)1 Projects (org.whole.lang.artifacts.model.Projects)1 FileArtifact (org.whole.lang.artifacts.reflect.ArtifactsEntityDescriptorEnum.FileArtifact)1