import #Openzeppelin/contrancts string literal (path) error - web3js

I am new at web3 and I am trying to fix this problem. it is about openzeppelin/contracts import error "Expected string literal (path), "" or alias list." and this is the error definition. I install openzeppelin/contracts but this problem was never solved. how can I fix it?
I am new at web[enter image description here][1]3 and I am trying to fix this problem. it is about openzeppelin/contracts import error "Expected string literal (path), "" or alias list." and this is the error definition. I install openzeppelin/contracts but this problem was never solved. how can I fix it?
pragma solidity ^0.8.4;
import '#openzeppelin\contracts\token\ERC721\ERC721.sol';
import '#openzeppelin\contracts\access\Ownable.sol';
contract safakNft is ERC721,Ownable{
uint256 public mintPrices;
uint256 public totalSupply;
uint256 public maxSupply;
uint256 public maxPerWallet;
bool public isPublicMintEnabled;
string internal baseTokenUri;
address payable public withdrawWallet;
mapping(address =>uint256) public walletMints;

Copy the "#openzeppelin" folder and paste it inside the "contracts" folder, then import it ( import "./#openzeppelin/contracts/token/ERC721/ERC721.sol";). Just remember to add it to the gitIgnore file (it should be dark blue after you done it).

Related

Why using a list of elements in selenium won't work but if I use WebDriver it works

I have this code which locate div elements in the dom I used selenium in order to find elements in the HTML page:
package com.indeni.automation.ui.model.alerts;
import com.indeni.automation.ui.model.PageElement;
import com.indeni.automation.ui.selenium.DriverWrapper;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import java.util.List;
public class FilterBar extends PageElement {
private List<WebElement> edgeDropDownMenus = driver.findElements(By.cssSelector("div.dropdown-menu.left"));
private List<WebElement> middleDropDownMenus = driver.findElements(By.cssSelector("div.combo-menu.left"));
public FilterBar(DriverWrapper driver){
super(driver);
}
public void clickOnIssuesDropDownMenu(){
clickButton(edgeDropDownMenus.get(0));
}
}
And this is clickButton function:
protected void clickButton(WebElement bthElm){
bthElm.click();
printClick(bthElm);
}
I am getting the following error:
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
but if I am using the following line of code it is working:
clickButton(driver.findElements(By.cssSelector("div.dropdown-menu.left")).get(0));
But I want to use the first elegant way but I can't figure out why am I getting this error message and how to fix it.
I am sorry to say that the first approach is not elegant. It is wrong to find the element when the class is initialized. When the class is initialized, those elements were not available. So the list would be basically empty. If you try to access any element from the list, it would throw the exception.
In your second approach, you find the element just before you click on it. That time it presents, so it works. This is the right way to do it.
If you want something elegant, Try something like this. With FindBy, we find the element, only when it is required. Not when the class is initialized. This is elegant and it will also work.
public class FilterBar extends PageElement {
#FindBy(css = "div.dropdown-menu.left" )
private List<WebElement> edgeDropDownMenus;
#FindBy(css = "div.combo-menu.left")
private List<WebElement> middleDropDownMenus;
public FilterBar(DriverWrapper driver){
super(driver);
PageFactory.initElements(driver, this);
}
public void clickOnIssuesDropDownMenu(){
clickButton(edgeDropDownMenus.get(0));
}
}

SSIS Data Flow Task Error: Object reference not set to an instance of an object

I am trying to create a package containing several Data Flow tasks in them. The tasks are fairly similar in nature, but contain fairly important differences.
I have tried to copy the task, then change the things which need changing.
When I run the task by itself it runs fine, however when I run it with all the other tasks in the package I get the below error:
Object reference not set to an instance of an object. at
ScriptMain.Input0_ProcessInputRow(Input0Buffer Row) at
UserComponent.Input0_ProcessInput(Input0Buffer Buffer) at
UserComponent.ProcessInput(Int32 InputID, String InputName,
PipelineBuffer Buffer, OutputNameMap OutputMap) at
Microsoft.SqlServer.Dts.Pipeline.ScriptComponent.ProcessInput(Int32
InputID, PipelineBuffer buffer) at
Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.ProcessInput(Int32
inputID, PipelineBuffer buffer)
Not the most friendly error message.
Can anyone tell me what this is and how to fix it? I assume that there is some variable or other attribute which is being repeated, but which one?
Note that many of the columns over the several data flow tasks will have the same column names.
I figured it out in the end. The reason was that the second level objects need to be explicitly declared.
I had
public class Level2
{
public string Somevalue { get; set; }
}
public class RootAttributes
{
public Level2 lvl2 { get; set; }
public string Somevalue2 { get; set; }
}
It should have been
public class Level2
{
public string Somevalue { get; set; }
}
public class RootAttributes
{
public Level2 lvl2 = new Level2;
public string Somevalue2 { get; set; }
}
The weird thing was that the top method worked in several other places.
I had this issue with my send mail task.
As I was using a file connection for my body of the email, I had to create a new file connection and it worked fine.
Use the package run report in vs 2012 to identify in which DFT task package got failed.
Use the view code option of the package to see the whether all the DFT task having proper input.

How can I export mongoDB collection into .csv which is readable/compatible in SQL Server

I used mongoexport to export the collection in to csv file along with fields. However when I tried to import the .csv in sql server using SSIS. I got errors and the data in preview section before executing the package was wrong. Can any one please guide me how can I export the data properly which can be easily imported into sql server. I am ready for minor tuning like adding id column or changing data types etc.
So it looks like you are getting a json formatted object for each row in the file. It may be different than that, and if that's the case, how you iterate through each might change a little. But here is something to get you started:
1 - There is no out of the box JSON parser in .NET, but this seems to be a popular utility: http://www.newtonsoft.com/json
2 - If you download the parser above, you'll have to go through a little pain to get it in a useable state with SSIS:
Go to the source folder and open the solution for net40
Sign the assembly
comment out the lines that cause build errors
//[assembly: InternalsVisibleTo("Newtonsoft.Json.Schema")]
//[assembly: InternalsVisibleTo("Newtonsoft.Json.Tests")]
install the assembly to the gac
3 - Once all that is out of the way, add a file connection manager to your package and point it to the mongdb file
4 - Add a dataflow and then add a script component source to the dataflow
5 - In the script component, configure the connection manager that you created in step three, I gave mine the friendly name "MongoDbOutput"
6 - In the Inputs and Outputs section, go to Output0 and add a column for each field in the JSON object, setting datatypes to string as they will be int by default
7 - Open the script and add a reference to Newtonsoft.Json and System.IO
8 - The script below shows how to access the connection string to the file in the connection manager, read the file with a streamreader one line at a time and then parse each JSON object for each address. One line is added for every address and the name and ssn are repeated for each line.
Note also, that I added a person and address class. The json.net is pretty cool, it will take that json and push it into the object - provided all the fields match up. Goog luck!
using System.IO;
using Newtonsoft.Json;
public override void CreateNewOutputRows()
{
object MongoDbPath = Connections.MongoDbOutput.AcquireConnection(null);
string filePath = MongoDbPath.ToString();
using (StreamReader fileContents = new StreamReader(filePath))
{
while (fileContents.Peek() >= 0)
{
var contents = fileContents.ReadLine();
Person person = JsonConvert.DeserializeObject<Person>(contents);
foreach (address address in person.addresses)
{
Output0Buffer.AddRow();
Output0Buffer.name = person.name;
Output0Buffer.ssn = person.ssn;
Output0Buffer.City = address.city;
Output0Buffer.Street = address.street;
Output0Buffer.country = address.cc;
}
}
}
}
public class Person
{
public string name { get; set; }
public string ssn { get; set; }
public address[] addresses
{ get; set; }
}
public class address
{
public string street { get; set; }
public string city { get; set; }
public string cc { get; set; }
}

java.lang.IllegalStateException : Attempting Create Multiple Associations On Variables of Class

first post here, hoping someone could perhaps shed some light on an issue I've been trying to juggle...
As a part of a school project we're attempting to build a interface to display points on a map and paths on a map.
For our first sprint I managed to work out storing/retrieving items using Objectify - it went great!
Now we're trying to extend the functionality for our next spring. Having problems now trying to store an object of type MapPath (note MapPath and MapData, our two data types, both extend class Data). Brief code snippets as follows :
#Entity
public class Data extends JavaScriptObject
{
#Id
Long id;
private String name;
private String dataSet;
...getters and setters
}
#Subclass
public class MapData extends Data implements Serializable{
{
private String name;
private String address;
private String dataSet;
#Embedded
private Coordinate location;
....constructors, getters/setters
}
#Subclass
public class PathData extends Data implements Serializable{
private String name;
private String address;
private String dataSet;
#Embedded
private Coordinate[] path;
...etc
}
Now hopefully I haven't lost you yet. I have a DataService class that basically handles all transactions. I have the following unit test :
#Test
public void storeOnePath(){
PathData pd = new PathData();
pd.setName("hi");
DataService.storeSingleton(pd);
Data d = DataService.getSingleton("hi");
assertEquals(pd,d);
}
The implementation of getSingleton is as follows :
public static void storeSingleton(Data d){
Objectify obj = ObjectifyService.begin();
obj.put(d);
}
JUnit complains:
java.lang.ExceptionInInitializerError
at com.teamrawket.tests.DataTest.storeOnePath(DataTest.java:59)
...<taken out>
Caused by: java.lang.IllegalStateException: Attempting to create multiple associations on class com.teamrawket.server.MapData for name
at com.googlecode.objectify.impl.Transmog$Visitor.addRootSetter(Transmog.java:298)
at com.googlecode.objectify.impl.Transmog$Visitor.visitField(Transmog.java:231)
at com.googlecode.objectify.impl.Transmog$Visitor.visitClass(Transmog.java:134)
at com.googlecode.objectify.impl.Transmog.<init>(Transmog.java:319)
at com.googlecode.objectify.impl.ConcreteEntityMetadata.<init>(ConcreteEntityMetadata.java:75)
at com.googlecode.objectify.impl.Registrar.registerPolymorphicHierarchy(Registrar.java:128)
at com.googlecode.objectify.impl.Registrar.register(Registrar.java:62)
at com.googlecode.objectify.ObjectifyFactory.register(ObjectifyFactory.java:209)
at com.googlecode.objectify.ObjectifyService.register(ObjectifyService.java:38)
at com.teamrawket.server.DataService.<clinit>(DataService.java:20)
... 27 more
What exactly does "attempting to create multiple associations on class ... for name" imply?
Sorry for the long post and any formatting issues that may arise.
You have repeated field names in your subclasses. You should not declare 'name' and 'dataSet' in both superclasses and subclasses; remove these fields from MapData and PathData and you should be fine.
com.teamrawket.server.MapData refers to the fullPath name for your MapData file. The name at the end refers to the field String name in your MapData class. This whole exception tries to tell you that it already contains a reference for that specific fullPath.
I would say there is another object with the same fullPath already registered. It would be helpful to know where line 59 is exactly as that is where the error occured.

GWT - Fail to Read properties

When I run in hosted mode, it able to get the result.
But when I deploy it to tomcat then I cant get the result at all.
Anyone can tell me what is the problem??
public class Customwidget implements EntryPoint {
private static final SystemConfig constants = (SystemConfig)GWT.create(SystemConfig.class);
public void onModuleLoad() {
Window.alert(constants.DBServerName());
}
SystemConfig.properties :
DBServerName=guaz
SystemConfig.java :
import com.google.gwt.i18n.client.Constants;
public interface SystemConfig extends Constants {
String DBServerName();
String DB_ServerName();
String DB_PortNumber();
String DB_DatabaseName();
String DB_IntegratedSecurity();
String DB_Password();
String DB_User();
}
thanks
Your properties files must be located/copied in the /WEB-INF/classes subfolder of your web application.

Resources