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;
}
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;
}
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;
}
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());
}
}
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();
}
Aggregations