Search in sources :

Example 31 with EnumMap

use of java.util.EnumMap in project neo4j-mobile-android by neo4j-contrib.

the class StandardExpander method temporaryTypeMapFrom.

private static Map<Direction, Collection<RelationshipType>> temporaryTypeMapFrom(Map<Direction, RelationshipType[]> typeMap) {
    Map<Direction, Collection<RelationshipType>> map = new EnumMap<Direction, Collection<RelationshipType>>(Direction.class);
    for (Direction direction : Direction.values()) {
        ArrayList<RelationshipType> types = new ArrayList<RelationshipType>();
        map.put(direction, types);
        RelationshipType[] existing = typeMap.get(direction);
        if (existing != null) {
            types.addAll(asList(existing));
        }
    }
    return map;
}
Also used : RelationshipType(org.neo4j.graphdb.RelationshipType) ArrayList(java.util.ArrayList) Collection(java.util.Collection) EnumMap(java.util.EnumMap) Direction(org.neo4j.graphdb.Direction)

Example 32 with EnumMap

use of java.util.EnumMap in project tdi-studio-se by Talend.

the class RepositoryService method exportPigudf.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.model.IRepositoryService#exportPigudf(org.talend.designer.runprocess.IProcessor,
     * org.talend.core.model.properties.Property, int, int)
     */
@Override
public String exportPigudf(IProcessor processor, Property property, boolean isExport) throws ProcessorException {
    // build java project
    CorePlugin.getDefault().getRunProcessService().buildJavaProject();
    Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
    exportChoiceMap.put(ExportChoice.needPigudf, true);
    ProcessItem processItem = (ProcessItem) property.getItem();
    ExportFileResource fileResource = new ExportFileResource(processItem, property.getLabel());
    ExportFileResource[] exportFileResources = new ExportFileResource[] { fileResource };
    IContext context = processor.getContext();
    //$NON-NLS-1$
    String contextName = "Default";
    if (context != null) {
        contextName = context.getName();
    }
    JobScriptsManager jobScriptsManager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, contextName, JobScriptsManager.ALL_ENVIRONMENTS, -1, -1, JobExportType.POJO);
    URL url = jobScriptsManager.getExportPigudfResources(exportFileResources);
    if (url == null) {
        return null;
    }
    File file = new File(url.getFile());
    // String librariesPath = LibrariesManagerUtils.getLibrariesPath(ECodeLanguage.JAVA) + "/";
    //$NON-NLS-1$
    String librariesPath = processor.getCodeProject().getLocation() + "/lib/";
    String targetFileName = JobJavaScriptsManager.USERPIGUDF_JAR;
    if (!isExport) {
        targetFileName = property.getLabel() + '_' + property.getVersion() + '_' + JobJavaScriptsManager.USERPIGUDF_JAR;
    }
    File target = new File(librariesPath + targetFileName);
    try {
        FilesUtils.copyFile(file, target);
    } catch (IOException e) {
        throw new ProcessorException(e.getMessage());
    }
    return targetFileName;
}
Also used : IContext(org.talend.core.model.process.IContext) JobScriptsManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager) ProcessorException(org.talend.designer.runprocess.ProcessorException) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) IOException(java.io.IOException) URL(java.net.URL) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) JSONObject(org.talend.utils.json.JSONObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) EnumMap(java.util.EnumMap) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 33 with EnumMap

use of java.util.EnumMap in project tesb-studio-se by Talend.

the class KarafJavaScriptForESBWithMavenManager method getOsgiWithMavenManager.

/**
     * DOC ggu Comment method "getOsgiWithMavenManager".
     *
     * @param contextgGroup
     * @return
     */
private OSGIJavaScriptForESBWithMavenManager getOsgiWithMavenManager(final List<ExportFileResource> list, final String talendJobLabel, String contextgGroup) {
    OSGIJavaScriptForESBWithMavenManager osgiWithMavenManager = new OSGIJavaScriptForESBWithMavenManager(new EnumMap<ExportChoice, Object>(this.exportChoice), contextgGroup, JobScriptsManager.LAUNCHER_ALL, IProcessor.NO_STATISTICS, IProcessor.NO_TRACES) {

        @Override
        protected Map<String, String> getMainMavenProperties(Item item) {
            Map<String, String> mavenPropertiesMap = super.getMainMavenProperties(item);
            // same group id with karaf
            mavenPropertiesMap.put(EMavenBuildScriptProperties.ItemGroupName.getVarScript(), getGroupId());
            return mavenPropertiesMap;
        }

        @Override
        protected void setMavenBuildScriptProperties(Document pomDocument, Map<String, String> mavenPropertiesMap) {
            super.setMavenBuildScriptProperties(pomDocument, mavenPropertiesMap);
            String itemName = mavenPropertiesMap.get(EMavenBuildScriptProperties.ItemName.getVarScript());
            if (itemName != null && pomDocument != null) {
                Element rootElement = pomDocument.getRootElement();
                // Because re-use the osgi bundle for service, but for artifactId, there is no "-bundle"
                // suffix. TDI-23491
                Element artifactIdEle = rootElement.element(IMavenProperties.ELE_ARTIFACT_ID);
                if (artifactIdEle != null) {
                    artifactIdEle.setText(itemName);
                }
            }
        }

        @Override
        protected String getTmpFolder() {
            return getSystemTempFolder().getAbsolutePath();
        }

        @Override
        public void setTopFolder(List<ExportFileResource> resourcesToExport) {
            super.setTopFolder(resourcesToExport);
            // TDI-23377, need reset the path and add it in for route exporting.
            for (ExportFileResource fileResource : resourcesToExport) {
                String directory = fileResource.getDirectoryName();
                fileResource.setDirectoryName(TALEND_JOBS_PATH + talendJobLabel + PATH_SEPARATOR + directory);
                // add to current route to export
                list.add(fileResource);
            }
        }
    };
    return osgiWithMavenManager;
}
Also used : CamelProcessItem(org.talend.camel.core.model.camelProperties.CamelProcessItem) Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) OSGIJavaScriptForESBWithMavenManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.esb.OSGIJavaScriptForESBWithMavenManager) ExportFileResource(org.talend.repository.documentation.ExportFileResource) Element(org.dom4j.Element) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) List(java.util.List) EList(org.eclipse.emf.common.util.EList) Document(org.dom4j.Document) Map(java.util.Map) EnumMap(java.util.EnumMap) HashMap(java.util.HashMap)

Example 34 with EnumMap

use of java.util.EnumMap in project tdi-studio-se by Talend.

the class ExportProcessorHelper method exportPigudf.

public void exportPigudf(IProcessor processor, Property property, int statisticsPort, int tracePort) throws ProcessorException {
    // build java project
    CorePlugin.getDefault().getRunProcessService().buildJavaProject();
    Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
    exportChoiceMap.put(ExportChoice.needPigudf, true);
    ProcessItem processItem = (ProcessItem) property.getItem();
    ExportFileResource fileResource = new ExportFileResource(processItem, property.getLabel());
    ExportFileResource[] exportFileResources = new ExportFileResource[] { fileResource };
    JobScriptsManager jobScriptsManager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, processor.getContext().getName(), JobScriptsManager.ALL_ENVIRONMENTS, statisticsPort, tracePort, JobExportType.POJO);
    URL url = jobScriptsManager.getExportPigudfResources(exportFileResources);
    if (url == null) {
        return;
    }
    File file = new File(url.getFile());
    File libFolder = JavaProcessorUtilities.getJavaProjectLibFolder();
    if (libFolder == null) {
        return;
    }
    File target = new File(libFolder.getAbsolutePath() + property.getLabel() + "_" + property.getVersion() + "_" + file.getName());
    try {
        FilesUtils.copyFile(file, target);
    } catch (IOException e) {
        throw new ProcessorException(e.getMessage());
    }
}
Also used : JobScriptsManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager) ProcessorException(org.talend.designer.runprocess.ProcessorException) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) IOException(java.io.IOException) EnumMap(java.util.EnumMap) File(java.io.File) URL(java.net.URL)

Example 35 with EnumMap

use of java.util.EnumMap in project kotlin by JetBrains.

the class LintDriver method computeRepeatingDetectors.

private void computeRepeatingDetectors(List<Detector> detectors, Project project) {
    // Ensure that the current visitor is recomputed
    mCurrentFolderType = null;
    mCurrentVisitor = null;
    mCurrentXmlDetectors = null;
    mCurrentBinaryDetectors = null;
    // Create map from detector class to issue such that we can
    // compute applicable issues for each detector in the list of detectors
    // to be repeated
    List<Issue> issues = mRegistry.getIssues();
    Multimap<Class<? extends Detector>, Issue> issueMap = ArrayListMultimap.create(issues.size(), 3);
    for (Issue issue : issues) {
        issueMap.put(issue.getImplementation().getDetectorClass(), issue);
    }
    Map<Class<? extends Detector>, EnumSet<Scope>> detectorToScope = new HashMap<Class<? extends Detector>, EnumSet<Scope>>();
    Map<Scope, List<Detector>> scopeToDetectors = new EnumMap<Scope, List<Detector>>(Scope.class);
    List<Detector> detectorList = new ArrayList<Detector>();
    // Compute the list of detectors (narrowed down from mRepeatingDetectors),
    // and simultaneously build up the detectorToScope map which tracks
    // the scopes each detector is affected by (this is used to populate
    // the mScopeDetectors map which is used during iteration).
    Configuration configuration = project.getConfiguration(this);
    for (Detector detector : detectors) {
        Class<? extends Detector> detectorClass = detector.getClass();
        Collection<Issue> detectorIssues = issueMap.get(detectorClass);
        if (detectorIssues != null) {
            boolean add = false;
            for (Issue issue : detectorIssues) {
                // the detector is enabled here.
                if (!configuration.isEnabled(issue)) {
                    continue;
                }
                // Include detector if any of its issues are enabled
                add = true;
                EnumSet<Scope> s = detectorToScope.get(detectorClass);
                EnumSet<Scope> issueScope = issue.getImplementation().getScope();
                if (s == null) {
                    detectorToScope.put(detectorClass, issueScope);
                } else if (!s.containsAll(issueScope)) {
                    EnumSet<Scope> union = EnumSet.copyOf(s);
                    union.addAll(issueScope);
                    detectorToScope.put(detectorClass, union);
                }
            }
            if (add) {
                detectorList.add(detector);
                EnumSet<Scope> union = detectorToScope.get(detector.getClass());
                for (Scope s : union) {
                    List<Detector> list = scopeToDetectors.get(s);
                    if (list == null) {
                        list = new ArrayList<Detector>();
                        scopeToDetectors.put(s, list);
                    }
                    list.add(detector);
                }
            }
        }
    }
    mApplicableDetectors = detectorList;
    mScopeDetectors = scopeToDetectors;
    mRepeatingDetectors = null;
    mRepeatScope = null;
    validateScopeList();
}
Also used : Issue(com.android.tools.klint.detector.api.Issue) LinkedHashMap(java.util.LinkedHashMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) EnumSet(java.util.EnumSet) ArrayList(java.util.ArrayList) ResourceXmlDetector(com.android.tools.klint.detector.api.ResourceXmlDetector) Detector(com.android.tools.klint.detector.api.Detector) Scope(com.android.tools.klint.detector.api.Scope) LintUtils.isAnonymousClass(com.android.tools.klint.detector.api.LintUtils.isAnonymousClass) PsiModifierList(com.intellij.psi.PsiModifierList) InsnList(org.jetbrains.org.objectweb.asm.tree.InsnList) ArrayList(java.util.ArrayList) PsiAnnotationParameterList(com.intellij.psi.PsiAnnotationParameterList) List(java.util.List) EnumMap(java.util.EnumMap)

Aggregations

EnumMap (java.util.EnumMap)156 Map (java.util.Map)30 HashMap (java.util.HashMap)23 Collection (java.util.Collection)22 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)18 DecodeHintType (com.google.zxing.DecodeHintType)17 List (java.util.List)14 IOException (java.io.IOException)12 EncodeHintType (com.google.zxing.EncodeHintType)11 BitMatrix (com.google.zxing.common.BitMatrix)11 Set (java.util.Set)11 Occur (org.apache.lucene.search.BooleanClause.Occur)10 Iterator (java.util.Iterator)9 ImmutableMap (com.google.common.collect.ImmutableMap)7 TreeMap (java.util.TreeMap)7 NoSuchElementException (java.util.NoSuchElementException)6 Bundle (android.os.Bundle)5 QRCodeWriter (com.google.zxing.qrcode.QRCodeWriter)5 URL (java.net.URL)5